I've been trying to get a good formula from what i know. But i cant get it to be exact. The problem is that it seem to be dependent on to many variables.
For instance we have one formula that says that the speed in the x-axis is the same, it never changes. So if we have that in mind we know that:
X (a distance) is equal to V0 * cos(a) * t
Where V0 is the starting velocity, the cos(a) i the cos for the angle at the start and t is the time it takes to travel the distance in x.
Okey, so we can rewrite cos(a) to be V0x / V0 which leads to "x = V0 * (V0x / V0) * t". We see that we can take away the "V0" part leading us to get:
"x = V0x * t". This is good, since I know my velocity in x to be the same all the time which means that the v0x is the same.
So we know x, since we have a waypoint that keeps track of the points we want Sarah to go. Perfect you might think! But it is here that it gets tricky. Why?
I'll try to explain.
So say that x is 200. That means Sarah is supposed to jump 200 pixels from her place here. Her speed in the x-axis must be atleast 11 (since my character im steering has 10 in speed, and i want Sarah to be faster then my character).
So this will give us the time for the jump.
In this case this means that the distance of 200 pixels with a speed of 11 pixels per update (i will refer the time as how many updates something will take. And my FPS is locked at 60 FPS, giving us 60 updates per seond. If you would rather count it as pixels per second or something).
Anyhow! This means that the jump will take 200/11 = 18.18181818... ~18.2 updates.
We also know that "y = V0 * sin(a) * t - ((g * t^2) / 2)
Where y represents the point at any time in the jump in the y-axis, the g is the gravity and the sin(a) is sin of the angle.
We can rewrite sin(a) as V0y / V0.
And as above this will lead to "y = V0y * t - ((g* t^2) /2).
Now we have three loose variables. The starting velocity V0y, the gravity g and the y.
But if we say that we will take the point where y is the highest, then we know that would be exactly the half of the time (18.2 updates).
And say that we take y to be "the difference in y + 128". Meaning if sarah will jump in the same y height, her maximum height will be 128 pixels above her position now. If she were to jump to a platform 64 pixels above her, her maximum height would be 128+64 = 192 pixels and so on. But for now, lets just focus on a jump 200 pixels away in the same y-height. This will give us y = 128 at the time of (18.2 / 2) = 9.1.
But the problem now is that we still have two loose variables, g and V0y, right?