Adding Sorting Elements

We covered Sorting Layers earlier in the chapter. Now let’s set up a couple of instances of them and see how we can add some simple depth and details to our level. Learning how to do this early will help when you have finished the level design and want to add details, and it may give you ideas for adding your own variations.

We will first add a fence GameObject to the foreground so that our Player GameObject will walk behind it. Then we will add water and a ledge. With the ledge sorted to be in front of the water, it will appear as though there is some depth in our Scene. These details will go a long way toward giving the game life.

1. Select the fence Prefab from the _prefabs folder. Place this roughly at the end of the ...

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.