- Home /
Player Character looses jump height the further right they go
Ok so I have my PlayerMovement controller going and have the character moving left and right, jumping, and double jumping. However after the character begins moving to the right the jumps get shorter and shorter. By the time you get to the 10th tile you no longer are able to jump at all. Any ideas on what this could be? There are no collision blocks causing it and none of the surrounding elements except the ground are considered solid.
The bug is probably in the code where the jumping force is applied. So seeing that code would be good starting point.
Answer by ksrajgame · Apr 11, 2017 at 08:02 AM
At the time of jump make sure that your vertical velocity set to Zero for example
2D GameObject:
rigidbody2D.velocity.y = 0;
rigidbody2D.AddForce(new Vector2(0, JumpForce));
rigidbody2D.velocity.y = 0;
won't work, you have to do as follow :
Vector2 velocity = rigidbody2D.velocity ;
velocity.y = 0 ;
rigidbody2D.velocity = velocity ;