Course contentsShow
← Unity Game Development
Lesson 12 of 8281. Unity FoundationsFree lesson

Establishing Parent-Child Hierarchies for Transform Inheritance

Organize complex scenes by nesting objects to ensure child entities inherit the transform properties of their parent containers.

Establishing Parent-Child Hierarchies for Transform Inheritance

In this lesson, you will learn how to organize complex scenes by nesting objects together so that child entities automatically inherit the movement, rotation, and scale of their parent.

Why Use Hierarchies?

Imagine you are building a simple car. Instead of manually moving the four wheels every time you want to move the car body, you can attach the wheels to the body. In Unity, we call the body the Parent and the wheels the Children. When you move or rotate the parent, all its children move and rotate along with it, maintaining their relative positions. This is called Transform Inheritance.

Creating a Hierarchy

To create a hierarchy in the Hierarchy Window, simply click and drag one GameObject onto another.

  1. Create a Cube (your "Car Body").
  2. Create a Sphere (a "Wheel").
  3. Drag the Sphere object directly onto the Cube object in the Hierarchy Window.

The Sphere will now appear indented under the Cube. If you select the Cube and move it using the Move tool, the Sphere will move perfectly in sync with it. You have established a Parent-Child relationship!

Understanding Local vs. Global Space

When an object is a child, its Transform coordinates in the Inspector change. They are no longer relative to the center of the entire 3D world (Global space); they are now relative to the parent’s position (Local space).

For example, if the parent is at (0, 10, 0) and the child is at (0, 0, 0) (relative to the parent), the child will appear exactly at the parent’s location. If you rotate the parent 90 degrees, the child will rotate around the parent, just like a planet orbiting a sun.

You can create deep hierarchies, such as nesting an exhaust pipe under a wheel, which is nested under the car body. Unity handles all the complex math for these nested transforms automatically.

Key Takeaway: By nesting GameObjects in the Hierarchy window, you create parent-child relationships where children inherit the spatial properties of their parent, allowing you to move and animate complex structures as a single unit.