Unity
Game Dev

To move a player in 3D Unity, beginners can use either Transform.Translate for simple movement or Rigidbody for physics-based control. This tutorial explains both methods step by step, including handling input, adding jump mechanics, and avoiding common mistakes. By the end, you’ll know how to move a player smoothly and start building interactive 3D games.

Project Manager Using AI for Workflow

Let’s face it. When you’re just getting started with Unity, building your first 3D game can feel a little overwhelming. One of the very first questions most beginners run into is simple but important: how do I move the player character around the scene? In this beginner Unity tutorial, we’ll break it down step by step. You’ll learn both the basics of moving a player with transforms and how to use physics for more realistic movement. By the end, you’ll have a character that glides smoothly across your 3D world.

Setting Up Your Unity Project

Before moving the player, make sure you have:

  1. A new 3D project in Unity.
  2. A player object — usually a Capsule (GameObject > 3D Object > Capsule).
  3. A ground plane — for example, a Plane to serve as the floor.
  4. A Main Camera positioned so you can see the player.

Rename the capsule to Player so it’s easy to keep track of.

Method 1: Moving with Transform.Translate

The simplest way to move a player in Unity is by directly changing its position using the Transform.Translate method.

Step 1: Create a Script

  1. In your Assets folder, right-click and select Create > C# Script.
  2. Name it PlayerMovement.
  3. Attach the script to your Player object.

Step 2: Add Movement Code
Open the script and paste the following:

using UnityEngine;

public class PlayerMoveSimple : MonoBehaviour
{
    public float speed = 5f;

    void Update()
    {
        float x = Input.GetAxisRaw("Horizontal");
        float z = Input.GetAxisRaw("Vertical");

        // Prevent diagonal speed boost
        Vector3 input = new Vector3(x, 0f, z);
        if (input.sqrMagnitude > 1f) input.Normalize();

        // Move in world space
        transform.Translate(input * speed * Time.deltaTime, Space.World);
    }
}

Breaking Down the Simple Movement (Transform) Script

This is the most straightforward way to move a player in Unity, perfect for learning or quick prototypes. Instead of using physics, we directly change the player’s position each frame.

1. Variables

  • A speed value controls how fast the player moves. You can adjust it in the Inspector.

2. Update Method (Input and Movement)

Since this script doesn’t rely on physics, everything happens in the Update method, which runs every frame.

  1. The script checks for keyboard input:
    • Horizontal input (A/D keys or left/right arrows).
    • Vertical input (W/S keys or up/down arrows).
  2. These inputs are combined into a movement vector.
  3. To keep movement consistent, the vector is normalized so diagonal movement isn’t faster than moving in just one direction.
  4. Finally, the player’s Transform component (the part that controls position, rotation, and scale) is updated to move the player in the scene.

Why Use Transform Movement?

  • It’s very easy to set up and understand.
  • Great for early prototypes or non-physics objects.
  • Ideal if your game doesn’t need collisions or realistic physics interactions.

Limitations

  • Since it bypasses Unity’s physics, the player can move through walls or other colliders.
  • Doesn’t respect forces like gravity.
  • Best for simple experiments, menus, or games without heavy physics.

This method is one of the easiest ways to get your player moving and is great for experimenting or building quick prototypes. It helps you understand how Unity handles positions and input without worrying about extra setup. Just remember that it ignores collisions and physics, so it’s best used as a simple starting point.

Method 2: Moving with Rigidbody (Physics-Based Movement)

If your player interacts with physics (like gravity or collisions), you’ll want to use a Rigidbody component instead.

Step 1: Add a Rigidbody
Select your Player object and in the Inspector click Add Component > Rigidbody.

Step 2: Update Your Script

using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerMoveRB : MonoBehaviour
{
    public float speed = 5f;

    Rigidbody rb;
    Vector3 input;

    void Awake()
    {
        rb = GetComponent<Rigidbody>();
        rb.freezeRotation = true; // prevent tipping
    }

    void Update()
    {
        float x = Input.GetAxisRaw("Horizontal");
        float z = Input.GetAxisRaw("Vertical");
        input = new Vector3(x, 0f, z);
        if (input.sqrMagnitude > 1f) input.Normalize();
    }

    void FixedUpdate()
    {
        Vector3 nextPos = rb.position + input * speed * Time.fixedDeltaTime;
        rb.MovePosition(nextPos);
    }
}

Breaking Down the Rigidbody Movement Script

Let’s go through what’s happening step by step so you understand how Rigidbody-based player movement works.

1. Rigidbody Requirement

[RequireComponent(typeof(Rigidbody))]

The script makes sure the player object has a Rigidbody component. This allows Unity’s physics system (gravity, collisions, etc.) to affect the player.

2. Variables

  • A speed value controls how fast the player moves (you can tweak it in the Inspector).
  • A Rigidbody reference stores the connection to Unity’s physics engine.
  • An input vector holds the movement directions coming from the keyboard.

3. Awake Setup

void Awake()
{
    rb = GetComponent<Rigidbody>();
    rb.freezeRotation = true;
}

When the game starts, the script grabs the Rigidbody component on the player. It also freezes the Rigidbody’s rotation so the capsule doesn’t tip over if it bumps into something.

4. Update Method (Input)

void Update()
{
    float x = Input.GetAxisRaw("Horizontal");
    float z = Input.GetAxisRaw("Vertical");
    input = new Vector3(x, 0f, z);
    if (input.sqrMagnitude > 1f) input.Normalize();
}

Every frame, the script checks for player input on the keyboard.

  • Horizontal input comes from the A/D keys or the left/right arrows.
  • Vertical input comes from the W/S keys or the up/down arrows.

These values are combined into a vector that points in the direction the player wants to move. The vector is normalized so diagonal movement isn’t faster than moving in a straight line.

5. FixedUpdate Method (Movement)

void FixedUpdate()
{
    Vector3 nextPos = rb.position + input * speed * Time.fixedDeltaTime;
    rb.MovePosition(nextPos);
}

Because the Rigidbody uses physics, movement is applied in FixedUpdate, which runs in sync with Unity’s physics engine. The script takes the player’s current position, adds the movement vector (scaled by speed and frame time), and then moves the Rigidbody to that new spot.

Why Use Rigidbody Movement?

  • It plays nicely with Unity’s physics, so collisions and gravity behave correctly.
  • It prevents problems like moving through walls or objects.
  • It’s easy to expand later with features like jumping, slopes, or pushing objects.

Using a Rigidbody is the better choice when you want your player to feel part of Unity’s physics world. This approach works with gravity, slopes, and collisions right out of the box, so the player won’t slide through walls or objects. It takes a tiny bit more setup, but it’s the go-to method for most 3D games once you move past prototypes.

Adding Jumping

OK, lets do one more thing. To make your tutorial more complete, let’s add a simple jump mechanic.

public float jumpForce = 5f;
private bool isGrounded = true;

void Update()
{
    if (Input.GetButtonDown("Jump") && isGrounded)
    {
        rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        isGrounded = false;
    }
}

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.CompareTag("Ground"))
    {
        isGrounded = true;
    }
}

Remember:

  • Input.GetButtonDown("Jump") maps to the Space bar.
  • We check if the player is grounded before applying jump force.

Common Beginner Mistakes

  1. Forgetting Time.deltaTime – without it, movement speed will depend on frame rate.
  2. Using Translate with Rigidbody – this can cause physics issues. If your player uses physics, stick to Rigidbody methods.
  3. Not setting up Input properly – check Edit > Project Settings > Input Manager if controls don’t respond.

Conclusion

Learning how to move a player in 3D Unity is one of the first big steps toward making your game feel alive. The Transform method is quick and simple, perfect when you are just testing ideas. The Rigidbody method takes a little more setup, but it gives you realistic movement that works with gravity, slopes, and collisions.

Start with whichever feels easier, experiment, and try both approaches. The more you practice, the more comfortable you will get with Unity’s tools, and soon you will be adding jumps, camera controls, and even custom character controllers of your own.

Looking for a reliable partner for your next project?

At SLIDEFACTORY, we’re dedicated to turning ideas into impactful realities. With our team’s expertise, we can guide you through every step of the process, ensuring your project exceeds expectations. Reach out to us today and let’s explore how we can bring your vision to life!

Contact Us
Posts

More Articles

Vision Pro Headset
Contact Us

Need Help? Let’s Get Started.

Looking for a development partner to help you make something incredible?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.