- Home /
Rigidbody jump adds bounce energy to second jump
I have a rigidbody attached to a sphere, I want to be able to jump from standstill an exact height every time, but setting the rigidbody velocity will make jumps while rolling up a hill less powerful (as there is already positive upward velocity).
The problem is, when I use RidigBody.AddForce(), the first jump is fine, but all subsequent jumps are higher. I am fairly sure that this is because the ball's bounce energy is being added to the jump. Is there a way fix this, but also allow falls from large heights to bounce high, even if the jump key is pressed?
Answer by Cakedown · Aug 02, 2013 at 07:32 PM
I did it with: rigidbody.velocity = new Vector3(0, jumpSpeed, 0);
This would work, except the ball may be rolling up or down a hill, in which case it would already have velocity in the y direction that needs to be taken into account, not just overwritten. Also, your code would make the ball stop in place by overwriting the velocity.x and velocity.z with 0.
Your answer
Follow this Question
Related Questions
How do I check when a rigidbody is colliding with the floor? 2 Answers
2D ball same bounce height on objects as on the ground 2 Answers
why my rigidbody ball either stops or bounces up when going from one surface to the next? 0 Answers
How could I make a bouncy object move mostly along the Z axis? 1 Answer
Help with making ball jump 4 Answers