#how to calculate the force necessary to reach an exact height

1 messages · Page 1 of 1 (latest)

worldly schooner
frosty cape
blissful loom
frosty cape
#

it works backwards

#

imagine yourself at 0 velocity at the top of the jump (the desired height)

#

it then simulates each fixed physics timestep, adding velocity as gravity would, until the object reaches the ground

#

the final velocity is the same as you would need to get to that height in the first place

blissful loom
#

oh

#

so basically

frosty cape
#

basically it's the same as if you drop an object off a height, then record its velocity as it hits the ground

#

that's the same velocity you'd need to throw the object to that height from the ground

blissful loom
#

if im at the desired height speed is 0, and then it calculates every physics frame until i get to 0?

frosty cape
#

yes

#

I'm not sure if there's a way to do it all at once (without a loop) but this should at least work as a starting point

blissful loom
#

i then do rb.addforce(CalculateInitialVelocity)

frosty cape
#

well this will just give you a float

#

so you'd use that as the y velocity you are assigning your player

#

something like cs rb.velocity = new(rb.velocity.x, CalculateInitialVelocity(desiredJumpHeight, Time.fixedDeltaTime, gravity), rb.velocity.z);

blissful loom
frosty cape
#

jump wherever you want to jump 🤷‍♂️

blissful loom