Jump to content
Search In
• More options...
Find results that contain...
Find results in...

# I suck at math, unsure how to devise formula, please help

## Recommended Posts

I need a way to calculate the minimum required velocity to reach a certain height assuming uninterrupted motion every tic. The purpose of this is alternate stepheight behavior, the player is allowed to exist below the floor so long as they are travelling upward with enough speed to reach the floor or higher by the time Z velocity hits 0 or less, if the speed is any less than that min. amount, they will be forced to floor level and their Z velocity set to 0.

I'm basically ready to implement this in my game, but I have no idea what formula I could use to return that value every tic when needed during step-up.

For upward momentum, I am using (in effect) a gravity level of 1.476 per tic (I have also disabled double application on first tic) and a friction level of 0.96. So yeah, I can't really use the formula for standard Doom physics, because I have butchered them. :P

#### Share this post

##### Link to post

First you need to give the exact formula for how velocity is adjusted every tic based on gravity, friction and all other relevant variables. The formula you want should be possible to derive out of it and is certainly impossible to find out without it.

#### Share this post

##### Link to post

I suck at maths too, so I'd just run a simulation. Hopefully the following is acceptably accurate!

The minimum upward velocity to reach height X should roughly correspond to the velocity you reach if you fell from height X. Now if you apply friction to vertical speed, this becomes a bit more complex, since it'll slow you down both ways.

If you didn't have friction, it'd be reasonably simple. Look for the smallest triangular number that is greater than the multiplied by your gravity constant. Let's say you want to climb 64 units, times 1.476 that gives you about 94.464, smallest triangular number greater than that is 105, so you need a vertical velocity of of 14.

Friction will make this a bit more complex since it always slows you down, regardless of direction. So you need to invert its value (1.042 instead of 0.96) when you measure the "virtual fall" from height X, to give you a final velocity that will overcome both gravity and friction to reach the desired height.

Note that due to the nature of triangular numbers, you quickly lose granularity, so perhaps bothering with friction might be overkill.

My advice overall would be to limit existence below the floor to just one tic or perhaps two or three. Then you can hardcode some acceptable values. The example above with a velocity of 14 would last ten tics. I would worry a bit about how much horizontal movement happens during these ten tics of allowed underground travel.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
×