CodeBlanks Logo Icon CodeBlanks

The Hierarchy window

Learn to organize GameObjects in the Hierarchy window.

Hierarchy window

The Hierarchy window lists all GameObjects in the active scene in a tree structure. Every cube, light, or camera added to the scene occupies a row in this list.

// Hierarchy view simulation:
// - World
//   - Player
//     - MainCamera

Sorting and grouping objects here keeps the scene organized and manageable.

Parent and Child behavior

When an object becomes a parent, child objects follow its movement. If the parent rotates or moves, the child moves along with it.

// Assigning parent via code
swordObject.transform.SetParent(playerObject.transform);

The child object's coordinates are then calculated relative to its parent (local space), rather than world space.

Practice Print hierarchy relationship

Set the parent object name to "Car" and child object name to "Wheel", then print in the format Parent: Car -> Child: Wheel.

Starter code

Player.cs
using System;

class Program
{
    static void Main()
    {
        // Parent ve Child isimlerini tanımlayıp yazdır
    }
}

Sample solution

Player.cs
using System;

class Program
{
    static void Main()
    {
        string parent = "Car";
        string child = "Wheel";
        Console.WriteLine("Parent: " + parent + " -> Child: " + child);
    }
}

Expected output

Parent: Car -> Child: Wheel

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What kind of relationship is established when an object is dragged into another in the Hierarchy?

  • Parent - Child relationship Correct answer
  • Only a temporary folder copy is created
  • The two objects are compressed into a single file
  • The lower object is automatically deleted from scene

Explanation: Dragging an object onto another establishes a Parent-Child hierarchy.

2 Set the parent object

Question
childTransform.____(parentTransform);
Answer
childTransform.SetParent(parentTransform);

Explanation: In the Unity C# API, SetParent is used to change an object's parent.

3 Hierarchy concepts

Term Meaning
Parent Top GameObject guiding objects below it
Child Object following its parent's motion
Hierarchy Window Panel showing scene objects in a tree
Local Position Object's position relative to its parent

All lessons in Beginner