Unusual jump behavior

I am following this course using the latest available version of Unity. Following the course instructions to implement a jump I am having unusual outcomes compared to what Rick achieves in the video:

With the jumpSpeed set to 5f (as in the vid), my player object will launch itself way up outside the outer reaches of the game canvas, and will also do so exponentially as long as the jump button is held (I assume this would be happening to Rick too, given the current way the code is written).

The project settings for 2d gravity seem to identical and I cannot seem to figure out what difference their is between what I have done and what is done in the video.

Hi,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

When you press the space bar, does the code add values to the velocity?

Hi,

Yes I have compared what I have with the project changes- it is adding the jumpVelocityToAdd Vector2 to the myRigidBody.velocity.

To be clear about what I mean, when I press the space bar it will keep adding this value at very small intervals. Even if I very lightly touch the space bar, this will give it chance to up to velocity quite a bit.

[EDIT]: Apologies, it was a stupid mistake- had used GetButton() rather than GetButtonDown(). Thanks for the help.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms