Move a player
About 15 minutes.
Learning objectives
- Build a plane and a cube named
Player - Add a complete
PlayerMoverscript that readsPlayer/Move - Confirm the cube moves on XZ in Play mode with WASD or arrows
This page uses project-wide actions (InputSystem.actions.FindAction). That is the required first workflow. The Player Input component page is optional and separate.
1. Add a ground plane
- In the Hierarchy, open GameObject > 3D Object > Plane.
You should see: a Plane at the origin in the Scene view.
Leave its transform at (0, 0, 0).
2. Add a Player cube
- In the Hierarchy, open GameObject > 3D Object > Cube.
- With the Cube selected, in the Inspector rename it to
Player. - Set Transform > Position to
X = 0,Y = 0.5,Z = 0.
You should see: the cube sitting on the plane, not intersecting it. A default cube is 1 unit tall, so Y = 0.5 puts the bottom on Y = 0.

3. Create a Scripts folder
- In the Project window, select the
Assetsfolder. - Right-click > Create > Folder.
- Name the folder
Scripts.
4. Create PlayerMover
- Select
Assets/Scripts. - Right-click > Create > MonoBehaviour Script (or Create > C# Script).
- Name it
PlayerMover. The filename must match the class name. - Double-click
PlayerMoverto open it in your editor. - Replace the entire file with this script:
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMover : MonoBehaviour
{
[SerializeField] float moveSpeed = 5f;
InputAction moveAction;
void Start()
{
moveAction = InputSystem.actions.FindAction("Player/Move");
}
void Update()
{
if (moveAction == null)
return;
Vector2 move = moveAction.ReadValue<Vector2>();
Vector3 delta = new Vector3(move.x, 0f, move.y) * moveSpeed * Time.deltaTime;
transform.Translate(delta, Space.World);
}
}
- Save the file.
- Return to Unity and wait for compile.
You should see: the Console has no compile errors. If you get CS0246 for InputAction, you missed using UnityEngine.InputSystem; — see Troubleshooting.
Why this matters:
FindAction("Player/Move")is the full path."Move"alone can collide if another map also has a Move action.move.xis world X.move.y(the Vector2 Y) is world Z, so the cube stays on the plane.
5. Add the component to Player
- Select
Playerin the Hierarchy. - In the Inspector, select Add Component.
- Choose Player Mover.
You should see: a Player Mover component on Player with Move Speed set to 5.
Do not add Player Input on this page. That is the next, optional workflow.
6. Frame the cube and check the camera
- Select
Playerin the Hierarchy. - Move the mouse over the Scene view and press F to frame the cube.
- Select Main Camera.
- If the Game view does not show the cube on the plane, adjust the camera so both are visible (a common starter pose is position
(0, 3, -6)looking toward the origin).
7. Enter Play mode
Edit mode does not run Update on your objects in a way that moves the cube for this test. You must enter Play mode.
- Press the Play button at the top of the Editor (or Ctrl/Cmd+P).
- Click the Game view so it has focus (the Editor does not send keystrokes to the game if a different window is focused).
- Hold W, A, S, D or the arrow keys.
You should see: the cube slides on the plane. W/Up moves along +Z, S/Down along -Z, A/Left along -X, D/Right along +X.

- Press Play again to stop.
Warning: Changes you make in Play mode (moving the cube by hand, changing
moveSpeed) are discarded when you stop. Set values in Edit mode.
If the cube does not move, open Troubleshooting before you continue.
8. Optional: gamepad
- Plug in a USB or Bluetooth gamepad that the OS already sees.
- Enter Play mode.
- Tilt the left stick.
You should see: the cube moves the same way as WASD. No script change is required because Move already has a stick binding.
Checkpoint
Before you continue:
Playeris a cube atY = 0.5on a PlanePlayerMoveris onPlayerand compiles- In Play mode, WASD or arrows move the cube on XZ
- You are not calling
Input.GetAxisorInput.GetKey
Next (optional): Player Input component. If something failed: Troubleshooting.