Page 1 of 1

Need help finding velocity needed to reach certain heights

Posted: Thu Sep 27, 2018 9:05 am
by Dark-Assassin
I'm trying to write a jump pad that will boost a player to a specific height using arguments or just use the sector's height if none are set.
However I have no idea how to find out how to determine the needed vertical velocity to reach those heights from the floor. It also needs to take account of variable gravity values too, not just Doom's 800.
I have everything but that formula. Results must be in fixed point too as it is done with ACS to keep compatibility with Zandronum.

If anyone could help me with this, it would be really appreciated.

Re: Need help finding velocity needed to reach certain heigh

Posted: Sat Sep 29, 2018 11:27 am
by Gutawer
The basic formula for this is the formula v^2 = u^2 + 2as, where v is the final velocity (we're looking at the top of a jump arc here, which is always when the velocity is 0, as the body is turning from going up to going down), u is the initial velocity, i.e. what you want, a is the acceleration (this is the actor's gravity as a negative value, i.e. -1 normally, but this can be gotten with ACS via APROP_Gravity, although this doesn't include sector/map gravity - I'm not sure how you'd get that in ACS), and s is the displacement, in this case this is height. So you have 0 = u^2 + 2as, which can be rearranged to make u = sqrt(-2as), which is the velocity you're looking for. Just as a general thing, I would also stick something like 64 units onto the height to add some lenience for things like numerical errors and the player needing to actually land on a ledge after reaching their top height, which will inevitably involve falling onto the ground.

Re: Need help finding velocity needed to reach certain heigh

Posted: Tue Oct 02, 2018 10:28 pm
by Dark-Assassin
Thanks. With a little tweaking to use fixed point numbers, I got this to work perfectly.