Lesson 2: GameObjects and Components - Building Interactive Objects

In Lesson 1 you created a scene and placed objects. Now you will unlock how Unity actually builds games: GameObjects and Components. Everything in your scene is a GameObject; what it does comes from the components you add. By the end of this lesson you will know how to create, configure, and combine components to build interactive objects.

Cat Sleep on Laptop by Dribbble Artist

Image: Cat Sleep on Laptop by Dribbble Artist

What You'll Learn

  • What GameObjects and Components are and how they work together
  • How to create and parent GameObjects in the Hierarchy
  • How to add, remove, and configure components in the Inspector
  • Essential built-in components (Transform, Mesh, Collider, Rigidbody)
  • How to build a simple interactive object from components

Prerequisites

  • Lesson 1 completed (Unity interface, first project, basic scene)
  • A Unity project open with at least one scene

Step 1: Understanding GameObjects

A GameObject is an empty container. It has a name, a position in the Hierarchy (and in the scene), and a list of Components. By itself it does nothing; components give it behavior and appearance.

  1. In the Hierarchy, right-click and choose Create Empty. A new entry appears (e.g. "GameObject").
  2. Rename it to something like Player or Obstacle.
  3. Select it and look at the Inspector. You will see at least one component: Transform. Every GameObject has a Transform (position, rotation, scale).

Pro tip: Think of a GameObject as a blank entity. Adding a "Mesh Filter" and "Mesh Renderer" makes it visible; adding a "Box Collider" makes it solid; adding a "Rigidbody" makes it fall. You build behavior by stacking components.

Step 2: The Transform Component

Transform is the only component every GameObject always has. It defines:

  • Position – location in the scene (X, Y, Z)
  • Rotation – orientation (degrees or quaternion)
  • Scale – size (1, 1, 1 = 100%)

Try this:

  1. Select your empty GameObject.
  2. In the Inspector, change Position (e.g. Y = 2) and Scale (e.g. 2, 2, 2).
  3. Watch the object move and grow in the Scene view. The Gizmo (arrows) shows position and orientation.

Common mistake: Resetting scale to (0, 0, 0) makes the object invisible and can break physics. Keep scale positive; use (0.01, 0.01, 0.01) only if you need something nearly invisible.

Step 3: Adding Components

Components are added from the Inspector.

  1. Select a GameObject.
  2. At the bottom of the Inspector, click Add Component.
  3. Search or browse (e.g. "Rigidbody", "Box Collider", "Light").
  4. Click the component to add it. Its properties appear in the Inspector.

You can add multiple components to one GameObject. For example: Mesh Filter (which shape) + Mesh Renderer (draw it) + Box Collider (collision) + Rigidbody (physics) = a box that falls and collides.

Pro tip: Use the Component menu or Add Component search instead of dragging scripts from the Project window. That way you see all built-in and project components in one place.

Step 4: Essential Built-in Components

Component Purpose
Transform Position, rotation, scale (always present)
Mesh Filter References the 3D mesh (shape) to display
Mesh Renderer Draws the mesh with a Material
Box / Sphere / Capsule Collider Defines collision shape for physics and raycasts
Rigidbody Makes the object simulated by physics (gravity, forces)
Light Adds a light source (Directional, Point, Spot)
Camera Renders the view (main camera is the player view)
Audio Source Plays sounds at the object's position

Try building a "falling box":

  1. Create Empty → name it FallingBox.
  2. Add Mesh Filter → set Mesh to "Cube" (built-in).
  3. Add Mesh Renderer → assign a Material (e.g. default or create one).
  4. Add Box Collider (fits the cube by default).
  5. Add Rigidbody.
  6. Press Play. The box should fall and land on any colliders below.

Step 5: Parenting and the Hierarchy

GameObjects can be parented to other GameObjects. The child moves, rotates, and scales with the parent.

  1. Create two GameObjects (e.g. "Parent" and "Child").
  2. Drag Child onto Parent in the Hierarchy. Child is indented under Parent.
  3. Move or rotate the Parent; the Child follows.
  4. Moving the Child only affects the Child relative to the Parent.

Use parenting to group related objects (e.g. a character with hat and weapon as children), to organize the Hierarchy, and to animate or script whole groups at once.

Pro tip: Empty parent GameObjects are often used as "folders" or pivot points. For example, a "Player" parent with "Model", "Collider", and "Effects" as children keeps the scene tidy and logic simple.

Step 6: Mini Challenge – Build a Simple Obstacle

Create an obstacle that has a visible shape, collides, and does not move (no Rigidbody):

  1. Create Empty → name it Obstacle.
  2. Add Mesh Filter → choose Cube or Sphere.
  3. Add Mesh Renderer → assign a Material.
  4. Add Box Collider (or Sphere Collider if you used a sphere).
  5. Do not add Rigidbody (so it stays fixed).
  6. Place it in the scene so your falling box lands on it when you press Play.

If your falling box passes through the obstacle, check that both have colliders and that the obstacle does not have "Is Trigger" enabled unless you want trigger behavior.

Troubleshooting

Object is invisible
Ensure it has a Mesh Filter (with a mesh assigned) and a Mesh Renderer (with a Material). Check that the camera can see it (not behind the camera or scaled to zero).

Object falls through the floor
Ensure the floor has a Collider (e.g. Box Collider or Mesh Collider). At least one object in a collision needs a Rigidbody for dynamic physics; the other can be static (collider only).

"Add Component" shows nothing useful
Make sure you are in the correct project and that the GameObject is selected. Use the search bar to filter by name (e.g. "Rigidbody", "Collider").

Changes in Play mode are lost
Unity resets the scene when you exit Play mode. Only changes applied in Edit mode are saved. Use this to experiment safely.

Summary

  • GameObjects are containers; Components define what they look like and how they behave.
  • Transform is on every GameObject (position, rotation, scale).
  • Use Add Component to add Mesh Filter, Renderer, Colliders, Rigidbody, Lights, etc.
  • Parenting in the Hierarchy groups objects and makes them move together.
  • You build gameplay by combining the right components on the right GameObjects.

What's Next

In Lesson 3: Transforms and Coordinates you will go deeper into positioning, world vs local space, and moving objects with the Transform API. You will use this to place and animate objects precisely in your levels.

← Previous: Lesson 1 – Unity Basics
Next: Lesson 3 – Transforms and Coordinates →

For more detail on the Hierarchy and prefabs, see our Unity guides. Bookmark this lesson and try the mini challenge in your own project to lock in what you learned.

FAQ

What is the difference between a GameObject and a Prefab?
A GameObject is an instance in a scene. A Prefab is an asset that stores a GameObject (and its components and children) so you can reuse it in many scenes. You will work with Prefabs in later lessons.

Can I remove the Transform component?
No. Every GameObject must have a Transform. It cannot be removed.

How many components can one GameObject have?
There is no hard limit. Keep GameObjects readable; if one has many components, consider splitting into child objects or prefabs for clarity.