jump pads problem
Posted
by
Pasquale Sada
on Game Development
See other posts from Game Development
or by Pasquale Sada
Published on 2012-09-26T22:18:01Z
Indexed on
2012/09/27
9:51 UTC
Read the original article
Hit count: 236
I'm trying to make a character jump on a landing pad who stays above him. Here is the formula I've used (everything is pretty much self-explainable, maybe except character_MaxForce that is the total force the character can jump ):
deltaPosition = target - character_position;
sqrtTerm = Sqrt(2*-gravity.y * deltaPosition.y + MaxYVelocity* character_MaxForce);
time = (MaxYVelocity-sqrtTerm) /gravity.y;
speedSq = jumpVelocity.x* jumpVelocity.x + jumpVelocity.z *jumpVelocity.z;
if speedSq < (character_MaxForce * character_MaxForce) we have the right time so we can store the value
jumpVelocity.x = deltaPosition.x / time;
jumpVelocity.z = deltaPosition.z / time;
otherwise we try the other solution
time = (MaxYVelocity+sqrtTerm) /gravity.y;
and then store it
jumpVelocity.x = deltaPosition.x / time;
jumpVelocity.z = deltaPosition.z / time;
jumpVelocity.y = MaxYVelocity;
rigidbody_velocity = jumpVelocity;
The problem is that the character is jumping away from the landing pad or sometime he jumps too far never hitting the landing pad.
© Game Development or respective owner