SCRIPTING • MOVEMENT

Unity GameObject Not Moving With Script

Step-by-step diagnostic checklist when your player, vehicle, or enemy remains completely stationary.

Quick Diagnostic Checklist

  1. Inspector Speed Variable Override: If you initialized float moveSpeed = 10f; in code, but previously attached the script to the GameObject, the Inspector stored the old value (often 0). Check the Inspector field and set it to 10.
  2. Script Component Disabled: Check the little checkbox next to your script name in the Inspector to make sure it is enabled.
  3. Paused Time (Time.timeScale == 0): If your game paused (e.g. death screen / menu), Time.deltaTime becomes 0, freezing all movement multiplied by delta time.
  4. Rigidbody Position Constraints: Check if Freeze Position X/Y/Z is enabled in Rigidbody constraints.

Movement Guides

Why Is My GameObject Not Moving in Unity? Complete Diagnostic Guide

When an object with an active movement script refuses to budge during Play Mode, it is almost always caused by one of five underlying physics or script execution traps:

  • Rigidbody Is Kinematic / Frozen Constraints: If isKinematic is checked, calling AddForce() has zero effect. Additionally, inspect the Constraints section—if Freeze Position X, Y, and Z are locked, PhysX will suppress all linear velocity.
  • Static Collider Conflicts: If a GameObject has a Collider but NO Rigidbody, modifying its transform.position forces Unity to recalculate the entire scene's static PhysX spatial tree every frame, causing massive CPU spikes and stuttering. Always attach a Rigidbody if an object is intended to move.
  • Time.timeScale Set to 0: If a pause menu or game-over screen executed Time.timeScale = 0f, any calculation multiplying by Time.deltaTime will result in a translation distance of zero.
  • Direct Collision Blocking: If an object is spawned overlapping another collider, PhysX collision resolution will continuously project the object backward to prevent interpenetration.
ReliableMovement.cs (Physics Best Practices)
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class ReliableMovement : MonoBehaviour
{
    [SerializeField] private float speed = 10f;
    private Rigidbody rb;
    private Vector3 inputDirection;

    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
        // Ensure interpolation is active for butter-smooth visual motion
        rb.interpolation = RigidbodyInterpolation.Interpolate;
    }

    private void Update()
    {
        // Capture input in Update
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");
        inputDirection = new Vector3(h, 0f, v).normalized;
    }

    private void FixedUpdate()
    {
        // Apply physics translation in FixedUpdate
        Vector3 targetVelocity = inputDirection * speed;
        rb.linearVelocity = new Vector3(targetVelocity.x, rb.linearVelocity.y, targetVelocity.z);
    }
}