I’ve been looking at this forum for multiple days now and it has been so helpful but I don’t know if I’m not looking up the right thing but I just can’t find out how to do this.
So I’m making a basic game that has a ball bouncing around the screen than a smaller ball in the corner of the screen and when I click I want it to move in the direction of the mouse(so where my mouse was at the time of the click then continues to move past it till it hits the ball and goes back to its origin). I hope this makes sense I have tried a couple of things but nothing works
Step one: Get the angle between the ball and the mouse. Google “get angle between two points” for a ton of resources.
Step two: Convert the angle to a unit vector, which is an x/y pair that you can think of as a heading. Google “convert angle to unit vector” for a ton of resources.
Step three: Multiply those x and y values of that unit vector by some speed to get the amount you should move the circle each frame.
The PVector class does offer some of this functionality. Check out the reference for a list of useful functions.
If you’re still stuck, please narrow your problem down to a MCVE. This can be as simple as one circle that follows the mouse. Good luck!
so right now I just have it to increase the x by 16 and decrease the y by 9 I would like to somehow make it so it goes to where the mouse was at the time of the clicks