Initial Player Movement. 2D SideScroller.

The first thing that i decided to code was the Bird movement code, this bit of code would allow the player to input wither the Space key, or the left mouse click, and the bird should jump to enable it to avoid hitting the objects in its way.

First, I declared my variables.I wanted to get my bird rigid body, and i declared what the jump amount is.


I then made sure that when the script was 'awoken' that the bird rigid body was declared and fetched from the bird.


Then I made sure that when the player either inputs SPACE or inputs LEFT MOUSE. the bird 'Jumps'

I then declared that jump meant that the bird rigid body velocity is determined by the vector 2 up motion multiplied by my jump amount variable.

My player could now jump whenever space or left mouse are inputted.



Comments

Popular Posts