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

Filed under:
|

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

Related posts about physics

Related posts about jumping

  • Smooth vector based jump

    as seen on Game Development - Search for 'Game Development'
    I started working on Wolfire's mathematics tutorials. I got the jumping working well using a step by step system, where you press a button and the cube moves to the next point on the jumping curve. Then I tried making the jumping happen during a set time period e.g the jump starts and lands within… >>> More

  • How can I improve my Animation

    as seen on Game Development - Search for 'Game Development'
    The first approaches in animation for my game relied mostly on sine and cosine functions with the time as parameter. Here is an example of a very basic jump I implemented. if(jumping) { height = sin(time); if(height < 0) jumping = false; // player landed player.position.z = height; } if(keydown(SPACE)… >>> More

  • Impulsioned jumping

    as seen on Game Development - Search for 'Game Development'
    There's one thing that has been puzzling me, and that is how to implement a 'faux-impulsed' jump in a platformer. If you don't know what I'm talking about, then think of the jumps of Mario, Kirby, and Quote from Cave Story. What do they have in common? Well, the height of your jump is determined by… >>> More

  • 3D Studio Max biped restrictions?

    as seen on Game Development - Search for 'Game Development'
    I have a stock biped character in 3D studio max which has a jump animation. The problem I have with the jump animation is that there is actual y offset happening inside it which makes it awkward to play while the character is jumping since it's not only jumping in the game world but the jump animation… >>> More

  • Jump handling and gravity

    as seen on Game Development - Search for 'Game Development'
    I'm new to game development and am looking for some help on improving my jump handling for a simple side scrolling game I've made. I would like to make the jump last longer if the key is held down for the full length of the jump, otherwise if the key is tapped, make the jump not as long. Currently… >>> More