Open links in new tab
    • JetBrains
      www.jetbrains.com › Rider › Unity
      About our ads

      Scripting editor for Unity - Debug scripts with one click

      SponsoredUse full-fledged debugger remotely or locally to debug Unity scripts & external libraries. Increase your productivity with on-the-fly Unity code analysis, generation and refactoring
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. Creating a movement script in Unity allows you to control a player or object using keyboard input. Below are two common approaches — one using Rigidbody physics and another using CharacterController for smooth movement.

    Rigidbody-Based Movement

    Steps:

    1. Attach a Rigidbody component to your player GameObject.

    2. Create a new C# script named PlayerMovement.

    3. Add the following code:

    using UnityEngine;

    public class PlayerMovement : MonoBehaviour
    {
    public float speed = 5f;
    public Rigidbody rb;

    void Update()
    {
    MovePlayer();
    }

    void MovePlayer()
    {
    float moveX = Input.GetAxis("Horizontal");
    float moveZ = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(moveX, 0, moveZ) * speed * Time.deltaTime;
    rb.MovePosition(transform.position + movement);
    }
    }
    Copied!

    Tip: Ensure rb is assigned in the Inspector and that the Rigidbody is set to Interpolate for smoother motion.

    CharacterController-Based Movement

    Steps:

    Feedback
  2. Add a movement script - Unity Learn

    In this Mission, you’ll program a simple interactive experience where you control a character in a living room scene and move around to collect objects. You'll be …

  3. Unity - Basic Movement Scripting - Online Tutorials Library

    In this lesson, we will write code that makes a gameObject move up, down, left and right based on the users input. This should help us understand the workflow of …

    Code sample

    void Update() {
      float h = Input.GetAxisRaw(“Horizontal”);
      float v = Input.GetAxisRaw(“Vertical”);
      gameObject.transform.position = new Vector2 (transform.position.x + (h * speed),
        transform.position.y + (v * speed));...
  4. Creating Simple 2D Player Movement and Jumping in …

    In this tutorial, we’ll walk through the process of setting up basic 2D player movement and jumping mechanics in Unity using a C# script. By the end of this …

  5. Simple Player Movement in Unity - Medium

    Aug 12, 2025 · In this article, I’ll walk you through each step I took to create simple player movement in Unity, so you can follow along with ease. Let’s begin by …

  6. Unity 3D Beginner Tutorial 2024: Creating a Movement Script

    Jul 31, 2024 · In this comprehensive guide, you'll learn how to create your first movement script using the W, A, S, and D keys. Perfect for beginners, this tutorial covers the basics of scripting in...

    • Author: SoloDev Tom
    • Views: 4.3K
  7. People also ask
    Loading
    Unable to load answer
  8. Unity Movement Scripting: A Beginner's Guide

    Mar 5, 2023 · With this beginner’s guide, you should have a solid understanding of the basics of movement scripting in Unity, including setting up your project, …

  9. Simple 3D Movement – ThatDevBoi

    Jul 20, 2024 · So, you’ve decided you want to create a Unity Project. You set up the project get familiar with the engine and then stumbled across the question; how …

  10. Unity - Scripting API: CharacterController.Move

    Description Supplies the movement of a GameObject with an attached CharacterController component. The CharacterController.Move motion moves the GameObject in the given direction. The given …