Hi,
I’m trying to develop a little sketch that manages the trajectory of balls that fall from the top of the canvas, as shown on this diagram.
I want each ball thrown from the top of the canvas to have a trajectory that points to the middle of the canvas at the bottom, where the stationary player is located. (represented here by a triangle).
Could someone suggest a piece of code that would be suitable?
I couldn’t find a piece of code that meets my needs and that uses the lerp( ) function or other trigonometric functions. But I adapted your idea based on “lerp( )” but using the “map( )” function.
It’s not very elegant nor very precise from the point of view of the real laws of mechanics, but it’s pretty much what I was looking for…
On my JsFiddle code snippet above, we can see that the farther the ball is dropped from the central axis, the less its fall converges towards the center.
If someone could suggest a small improvement to correct this drawback, I would be interested!