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
isKinematicis checked, callingAddForce()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
Colliderbut NORigidbody, modifying itstransform.positionforces 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 byTime.deltaTimewill 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);
}
}