1. Lesson Overview
Have you ever wondered how game developers make a character appear in front of mountains but behind trees? In this project, you are a 2D game scene designer. You will create a sky, mountain, player, bush, and tree and control which graphics appear in front.
2. Learning Objectives
- Explain the purpose of sprites and sorting layers.
- Create and position 2D sprites within a Unity scene.
- Create Background, Player, and Foreground sorting layers.
- Use Order in Layer to control sprite visibility.
- Demonstrate correct visual overlap between objects.
- Save and submit a completed Unity scene.
3. Key Vocabulary
| Term | Definition |
|---|---|
| Sprite | A 2D image used as a game object. |
| Sprite Renderer | The Unity component that displays a sprite. |
| Sorting Layer | A group determining which sprites appear in front of other groups. |
| Order in Layer | A number controlling draw order within the same Sorting Layer. |
| Hierarchy | The Unity window listing GameObjects in the scene. |
| Inspector | The window where you edit a GameObject's properties. |
| Foreground | Objects drawn in front, closer to the viewer. |
| Background | Objects drawn behind, farther from the viewer. |
4. Guided Project: Build Your Scene 30–35 min
Step 1 — Create a Unity Project
- Open Unity Hub and select New Project.
- Choose a 2D project template.
- Name the project
Lesson04_LayeredSceneand select Create Project. - Save your scene as
LayeredAdventureusing File → Save As.
If you have a 2D project from earlier lessons, you may create a new scene in that project instead.
Step 2 — Create Your Background
- In the Hierarchy, right-click and select 2D Object → Sprites → Square (menu wording may vary).
- Rename it
Sky; set Sprite Renderer Color to light blue. - Set Position to
(0, 0, 0)and Scale to(18, 10, 1). - Create another Square sprite named
Mountainand color it gray or dark green. - Set Mountain Position to
(-2, -1, 0)and Scale to(5, 4, 1).
Step 3 — Create the Player
- Create a Capsule sprite (or a Square if Capsule is unavailable).
- Rename it
Playerand color it red, yellow, or blue. - Set Position to
(0, -1, 0)and Scale to(1, 1.5, 1).
Step 4 — Create Foreground Objects
Bush: Create a Circle sprite named Bush, color it green, set Position to (0.4, -1.5, 0) and Scale to (1.6, 0.9, 1).
Tree trunk: Create a Square sprite named TreeTrunk, color it brown, set Position to (3, -0.5, 0) and Scale to (0.5, 3, 1).
Tree leaves: Create a Circle sprite named TreeLeaves, color it dark green, set Position to (3, 1, 0) and Scale to (2, 2, 1).
Step 5 — Create Sorting Layers
- Open Edit → Project Settings → Tags and Layers.
- Find the Sorting Layers section.
- Add
Background,Player, andForeground. - Place them in that order, top to bottom, in the Sorting Layers list.
Step 6 — Assign Each Sprite to a Layer
Select each object in the Hierarchy, locate Sprite Renderer in the Inspector, and set its Sorting Layer and Order in Layer as follows:
| Sprite | Sorting Layer | Order in Layer |
|---|---|---|
| Sky | Background | 0 |
| Mountain | Background | 1 |
| Player | Player | 0 |
| Bush | Foreground | 0 |
| TreeTrunk | Foreground | 1 |
| TreeLeaves | Foreground | 2 |
Step 7 — Test the Scene
- Select the Player and move it slightly left and right in the Scene view.
- Confirm the player appears in front of the mountain.
- Move the Player behind the Bush and confirm that the Bush covers part of the Player.
- Open the Game view to inspect the result.
- Save the scene.
5. Interactive Practice — Predict Sprite Ordering
Change the assigned Sorting Layer for each object, and observe the conceptual preview. Restore the correct three-layer arrangement when you finish.
This demonstration uses a simplified drawing order; Unity also considers Order in Layer and other renderer settings.
6. Independent Student Challenge 10 min
Add three new sprites such as clouds, rocks, flowers, or another character. Then place two overlapping objects on the same Sorting Layer with different Order in Layer values.
Example: Put two clouds in the Background sorting layer with Order in Layer values of 2 and 3. Overlap them to verify which appears in front.
Extra credit: Build a more detailed forest, beach, village, castle, or space theme.
7. Knowledge Check
Choose the best answer for each question. Select Grade Quiz to see your score and explanations.
8. Project Grading Rubric
| Requirement | Points |
|---|---|
| Unity scene created and saved correctly | 10 |
| Background objects created and positioned | 15 |
| Player sprite created and visible | 15 |
| Foreground objects created and positioned | 15 |
| Three correct sorting layers | 20 |
| Correct use of Order in Layer | 15 |
| Independent challenge: three additional sprites | 10 |
| Total | 100 |
Students must demonstrate correct layering, not simply place objects in different locations.
9. Student Submission Checklist
Check each requirement as you finish it:
10. Teacher Notes
Pacing: Introduction (5 min), demonstration (5 min), guided creation (30 min), challenge (10 min), and assessment (5 min).
Common misconception: The GameObject's regular Layer field at the top of the Inspector is not the same as the Sorting Layer field in Sprite Renderer. Reordering objects in the Hierarchy also does not automatically determine sprite drawing order.
Troubleshooting: If a sprite is invisible, confirm its Sprite Renderer is enabled, its position is within the camera view, its scale is appropriate, and its sorting settings are correct.
Demonstration: Temporarily assign the Bush to Background, ask students what will happen, then restore it to Foreground and discuss the visual result.
Further Reading
Unity Manual — Tags and Layers | Unity Manual — Sprite Renderer
Lesson Completion Goal
Explain how a 2D game creates the illusion of depth by drawing sprites in a controlled order — and demonstrate that knowledge by building a layered adventure scene.