Course contentsShow
← Unity Game Development
Lesson 93 of 8282. Scripting and LifecycleFree lesson

Understanding Local Versus Global Coordinate Systems

Learners will differentiate between world space coordinates and local space coordinates to predict how objects behave when moved in a 3D scene.

In this lesson, you will learn how to distinguish between world space and local space to predict exactly how your objects move within a 3D scene.

The Two Perspectives of Space

In Unity, every object’s Transform component tracks its position, rotation, and scale. However, Unity tracks these values in two different ways: Global (World) Space and Local Space.

Global Coordinate System

Think of Global Space as the "absolute" grid of your entire game scene. The center of the world is at the coordinates (0, 0, 0). No matter where you place an object, its position in Global Space is calculated relative to that static, universal center point. When you select an object in the Inspector and see its Transform values, you are usually looking at its global position.

Local Coordinate System

Local Space is defined by an object’s parent. If an object has no parent, its local space is identical to the global space. However, if you "parent" an object to another (like putting a sword inside a character's hand), the sword’s position is now calculated relative to the hand. If you move the character, the sword moves with it—even though the sword’s local coordinates stay the same relative to the hand.

Visualizing the Behavior

Consider this simple script logic:

// Moving relative to the object's own orientation (Local)
transform.Translate(Vector3.forward * Time.deltaTime);

// Moving relative to the scene's fixed axes (Global)
transform.position += Vector3.forward * Time.deltaTime;

When you use transform.Translate, Unity calculates the movement based on the object's local "forward" direction. If your character is rotated to face right, "forward" points to the right of the scene. In contrast, using transform.position bypasses the object's local orientation and pushes it along the global Z-axis, regardless of which way the object is facing.

Understanding this distinction is vital: if you want a car to drive forward, you use local space. If you want an object to move toward the North (global Z) regardless of its rotation, you use global space.

Key Takeaway: Global space provides an absolute position within the scene, while local space provides a position relative to an object's parent, allowing objects to move naturally with their environment.