In this lesson, you will learn how to navigate the crucial distinction between World Space and Local Space when moving, rotating, or scaling your GameObjects.
Understanding the Two Frames of Reference
When you look at the Transform component in the Inspector, you are seeing values that change depending on where that object sits in your Hierarchy.
- Global Space (World Space): This is the "absolute" coordinate system of the entire scene. If an object is at
(0, 0, 0)in World Space, it is at the very center of your game world. - Local Space: This is the coordinate system relative to an object's Parent. If an object is a child of another, its position is measured based on the parent’s origin, not the world’s origin.
Why It Matters
Imagine you have a "Car" object and a "Wheel" object that is a child of that car. If you move the Car, the Wheel moves with it because it inherits the Car's transform.
When you look at the Wheel's Transform component in the Inspector:
- The Position you see is Local. If the wheel is sitting on the axle, its local position might be
(1, 0, 0). - However, because the Car is moved to a new spot in the world, the Wheel's Global position is actually different (e.g.,
(11, 0, 5)).
Toggling Views in the Scene View
You can easily see these differences using the tools at the top left of the Scene View. You will see two buttons: Global and Pivot/Center.
If you click the button that says Global, it will toggle to Local. When set to Local, the move/rotate gizmo will align with the object’s own rotation. If you rotate a cube 45 degrees and then move it in "Local" mode, the arrows will tilt to match the cube, allowing you to slide it perfectly along its own surface. When in "Global" mode, the arrows always point strictly along the world's X, Y, and Z axes, regardless of how the object is tilted.
Key Takeaway: Global space provides the object's position within the entire scene, while Local space provides its position relative to its parent, making it easier to adjust parts of a hierarchy without breaking their relationship.