Character flying straight up without going down.

Hello.
So I am following currently a tutorial for making a simple 2d runner game. After a time of coding and trying to run my code, I noticed that after I press Space, the player just goes up without falling, even when I remove my finger from the Space. I’ve also tried to write a code which makes the character automatically fall after 0.5 seconds of constant pressing Space, without any good result. Here is the code (I uploaded the .cs file):

What did I do wrong in the coding which made the player not go down? THX for helping.

7564162–936121–Player.cs (1.61 KB)

Hey,

If you set the “gravity” variable to a negative number then you should fall back down.

Thank you so much! I didn’t notice I did not set that value to negative, which took me over a day of figuring out what the problem was. You are really a hero! (I am new to Unity so stuff like this are very common to face me).

1 Like