In this lesson, you will learn how to distinguish between local and global coordinate spaces to predict how moving a parent object affects its children.
The World (Global) Space
When you look at the entire Unity scene, you are looking at Global Space. Every object in the game has a position based on the center of the world, which is the coordinate (0, 0, 0). If you select an object and see its Transform values while it is not parented to anything, you are looking at its global coordinates. This is the "absolute" position of the object in your game world.
The Parent (Local) Space
Once you create a hierarchy, things change. If you drag a Cube into an Empty GameObject, the Cube becomes a child. The Cube now has Local Space coordinates. These coordinates are relative to its parent’s position, not the center of the world.
If the parent is at (10, 0, 0) and the child is at (1, 0, 0) in local space, the child will actually appear at (11, 0, 0) in the world.
Why This Matters
Think of this like being a passenger in a car:
- Global Space: Your position on the map (e.g., "I am at the intersection of 5th and Main").
- Local Space: Your position inside the car (e.g., "I am sitting in the passenger seat").
If the car moves, your global position changes, but your local position—sitting in that seat—remains exactly the same. In Unity, when you move a parent, all its children move with it because they maintain their relative distance (their local coordinates) from that parent.
To see this in action, you can toggle the tool handle handle at the top-left of the Scene view between Pivot/Center and Global/Local. If you set it to Local, your move handles will align with the rotation of the object itself, rather than the world axes.
// The child's position is relative to the parent
childTransform.localPosition = new Vector3(0, 5, 0);
// The child's position in the world regardless of the parent
childTransform.position = new Vector3(0, 5, 0);
Key Takeaway: Global space coordinates define an object's position relative to the world center, while local space coordinates define an object's position relative to its parent's pivot point.