High School • Unity Game Engine • Lesson 4

Build a Layered Scene

Create a background, player, and foreground using correct sprite ordering. Learn to build depth in a 2D game — no coding required.

Difficulty: Very EasyGrades 9–1245–55 minutesSprites • Sorting Layers • Order in Layer

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.

BACKGROUNDSky and mountains PLAYERMain character FOREGROUNDTree and bush
Imagine three transparent sheets stacked on top of each other. The background is drawn first, the player next, and the foreground last.

2. Learning Objectives

  1. Explain the purpose of sprites and sorting layers.
  2. Create and position 2D sprites within a Unity scene.
  3. Create Background, Player, and Foreground sorting layers.
  4. Use Order in Layer to control sprite visibility.
  5. Demonstrate correct visual overlap between objects.
  6. 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

  1. Open Unity Hub and select New Project.
  2. Choose a 2D project template.
  3. Name the project Lesson04_LayeredScene and select Create Project.
  4. Save your scene as LayeredAdventure using 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

  1. In the Hierarchy, right-click and select 2D Object → Sprites → Square (menu wording may vary).
  2. Rename it Sky; set Sprite Renderer Color to light blue.
  3. Set Position to (0, 0, 0) and Scale to (18, 10, 1).
  4. Create another Square sprite named Mountain and color it gray or dark green.
  5. Set Mountain Position to (-2, -1, 0) and Scale to (5, 4, 1).

Step 3 — Create the Player

  1. Create a Capsule sprite (or a Square if Capsule is unavailable).
  2. Rename it Player and color it red, yellow, or blue.
  3. 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).

You should now have at least six sprites. This scene is illustrative: squares and circles are acceptable for this beginner lesson.

Step 5 — Create Sorting Layers

  1. Open Edit → Project Settings → Tags and Layers.
  2. Find the Sorting Layers section.
  3. Add Background, Player, and Foreground.
  4. Place them in that order, top to bottom, in the Sorting Layers list.
Important: In Unity's Sorting Layers list, lower layers are drawn in front of higher layers.

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
Within the same Sorting Layer, a sprite with a higher Order in Layer appears in front of a sprite with a lower value.

Step 7 — Test the Scene

  1. Select the Player and move it slightly left and right in the Scene view.
  2. Confirm the player appears in front of the mountain.
  3. Move the Player behind the Bush and confirm that the Bush covers part of the Player.
  4. Open the Game view to inspect the result.
  5. 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:

0 of 6 complete
Submit: (1) Screenshot of your Game view, (2) screenshot of Sprite Renderer settings showing Sorting Layer and Order in Layer, and (3) your Unity project or saved scene as directed by your teacher.

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

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.