Adding Walls to the Level

By now you should be very familiar with the process of creating a new GameObject and getting the basic elements set up. This is something that you’ll do constantly when working in Unity, until you eventually have a full library of Prefabs from which to draw.

1. Create an empty GameObject and name it “Box.”

2. Add a Sprite Renderer Component to it.

3. Set the Sprite Renderer’s “Sprite” property to tiles_spritesheet_135.

4. Click the Add Component button and select Physics 2D > Box Collider 2D.

5. Set the GameObject’s Layer to Ground, as this is something the player can stand on and, therefore, should refresh the player’s flag for double jumping.

In order to make our walls work, we need a new tag and a wall Prefab so that ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.