I’ve looked around for a while trying to find a good way to go about doing parabolic motion but I’m still having trouble. The idea is that I have a starting point, and ending point, and then either an initial angle or max height of the curve (doesn’t really matter) and I need the projectile to travel through this curve. I looked at several tutorials but I cannot find one that supports using points other than roots, for example, the points (10, 20) and (50, 30). Since the y values are different I don’t know how to go about using the formulas I found.
Here’s what I have so far:
private var speedX:Number;
private var speedY:Number;
.
.
.
var g:Number = 1; // gravity
var sx:Number = en.x - x; // where x is the starting location and en.x is the ending location
var sy:Number = y - en.y; // same for y
var o:Number = 45; // launch angle
var v:Number = (Math.sqrt(g) * Math.sqrt(sx) * Math.sqrt((Math.tan(o) * Math.tan(o)) + 1)) / Math.sqrt(2 * Math.tan(o) - (2 * g * sy) / sx); // velocity
speedX = Math.cos(o) * v;
speedY = Math.sin(o) * v;
and then in my update function
x += speedX;
y -= speedY;
speedY -= 0.25;
It seems to work decently with most values, but when the ending location’s y value is lower than that of the starting location, it kinda just shoots straight down.
How could I go about doing this? Thanks!