- Home /
Mimic realistic gravity for player jump C#
Summary
Trying to re-create a realistic jump for a rigidbody.
What I have been doing
I have been playing around the Rigidbody2d component, trying combinations between mass, gravity... When the user presses Jump I add an upwards force.
For example : rigidbody2D.AddForce (transform.up * 200f);
I just can't get a realistic jump, it looks like the character is floating or too heavy... any suggestions or different techniques I can try.
Answer by goibon · Mar 12, 2014 at 10:41 AM
Had it been a regular Rigidbody you would have changed the ForceMode to Impulse, but when using Rigidbody2D it seems that you have to calculate the force yourself. To get the impulse effect this should work:
Vector2 force = (transform.up * force) / Time.fixedDeltaTime;
rigidbody2D.AddForce(force);
Then try fiddling around with the mass of your Rigidbody2D and the force applied to get the right jump height.
Your answer
Follow this Question
Related Questions
rb.addforce being really buggy 2 Answers
jump and land quicker 2 Answers
How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers
Change rigidbody's jumping speed 2 Answers
How to drag object faster to the ground? 3 Answers