Moving the Player Object

Rook Sullivan
2 min readMar 31, 2021

--

Now that we have everything set up, its time to learn how to use Unity!
We will want to start with a clean slate, so lets remove everything we created previously and create a new Cube object. This will be the Player, and we can name it as such. For learning and prototyping, simple objects like this allow us to get things in the game quickly, and can be replaced later during the process.
With the player object created, we can set it up with a simple material and script. With the player assigned a script, we can begin to modify the script to cause the Player to move.
We will want the Player to start from a designated spot, and we can do this by calling the position function of the Transform component. We do this within the Start function so when the game starts, the position of the object is snapped to where it is supposed to be. This is done by calling on a Vector3, which defines all position types in Unity.

The same tools we used to set the initial position of the Player can also be used to move the player. Within the Update function, we can tell the Player object to move a specified distance each time it is called, which is once per frame, or 60 times per second.

--

--

Rook Sullivan
Rook Sullivan

Written by Rook Sullivan

Non-binary game dev sharing my experiences in Unity.

No responses yet