Player Setup Part 1

Simon Leen
2 min readSep 16, 2021

Objective: Set up Player Idle Sprites and Basic Movement

The above image is the spritesheet for the Players idle animation. We will follow the same process as before to slice this up into frame sprites.

Next we create an empty object in the scene and reset the position. Rename it Player then drag the first frame of the idle sprites into the Player, rename it Sprite and reset its position. Now we create a Player script inside a seperate scripts folder and attach it to the Player object. Add a Rigidbody 2D and a box Collider 2D to the Player then edit the collider settings and bounds to match the Player.

Open the script and create a private Rigidbody2D and assign it in the Start method using GetComponent. Next in the Update method, create a float for the horizontal(X-Axis) movement and set it to the GetAxisRaw input of horizontal. We use the Raw version for a better response of either 0 or 1 values instead of a value between 0 and 1. Next set the Rigidbody velocity to a new Vector2 using the horizontal float and the rigidbody Y-axis velocity(We will need this later instead of setting it to 0).

We now have basic movement. In a later post we will work on the animations from the spritesheet we sliced earlier.

--

--