Simple Player Movement in Unity

Richard Morgan
Apr 25, 2021

--

Moving objects in Unity is done by updating the Transform on the game object. All game objects have transforms. In this example, the Player game object Transform is set to just below the center on the Y coordinate:

To move the game object, add a script to the object that contains a Transform translation. This simple transform centers the position of the game object when the games starts:

Translating the transform in the Update will cause the object to be repositioned on the screen with every frame update. Use Time.deltatime to convert the updates to seconds instead of frames:

Here, you can see the results — the game object is first centered on Start () and then moved 1 meter per second from Update():

--

--

Richard Morgan
Richard Morgan

Written by Richard Morgan

Unity developer interested in AI integrations.

No responses yet