GameObjects and Components: Unity's Building Blocks
Snapshot
~70 sec
A GameObject is an empty container; a Component is a small, attachable slice of behavior or data. Unity builds everything - a player, a light, a UI button - by composing components onto a GameObject instead of inheriting from a deep class tree.
You will learn
- Explain why Unity favors composing components over inheriting behavior.
- Name what a bare GameObject can and cannot do on its own.
- Predict what happens when you add or remove one component from an object.
Target outcome
You can describe any invented object as a GameObject plus a short list of components, each with one job.
Visual walkthrough
Visual walkthrough
~5 min
Four ideas that make up the model
GameObject
A named container that exists in a scene. Empty on its own - it does nothing.
Component
A small unit attached to a GameObject that gives it one capability (move, render, collide).
Transform
The one component every GameObject always has: its position, rotation, and scale.
Composition
Building behavior by attaching several focused components instead of one large class.
One invented pickup, built from three components
The GameObject itself stays empty. Each attached component contributes exactly one capability, and removing one only removes that capability.
GameObject: "CoinPickup"
Transform
Where the coin sits in the scene.
Sprite Renderer
Draws the coin's visible shape.
Circle Collider 2D
Defines the shape that detects the player.
CoinValue (script)
Owns the invented pickup amount and the collect reaction.
- Sprite RendererCircle Collider 2Dshares position with
- Circle Collider 2DCoinValue (script)triggers
The GameObject itself stays empty. Each attached component contributes exactly one capability, and removing one only removes that capability. Reading order
- Transform
Where the coin sits in the scene.
- Sprite Renderer
Draws the coin's visible shape.
- Circle Collider 2D
Defines the shape that detects the player.
- CoinValue (script)
Owns the invented pickup amount and the collect reaction.
Connection explanations
- Sprite Renderer → Circle Collider 2D (shares position with)
Both read the same Transform, so the visible shape and the detection shape move together automatically.
- Circle Collider 2D → CoinValue (script) (triggers)
The collider only detects overlap; the script owns what happens next, keeping detection and reaction separate.
Diagnose a bare GameObject
You create an empty GameObject named "Enemy" and press Play. Nothing appears and nothing moves. Why, and what is the smallest fix?
Expected reasoning
An empty GameObject has only a Transform - no visible shape, no behavior. Add a renderer component (to draw it) and a script or animator component (to move it). The object was never broken; it simply had no components giving it those capabilities yet.
Go deeper
- Unity Manual: GameObjectsFull reference for GameObjects and the component model.