< Back
Page 7 of 7
This chapter is from the book
Exercises
- Finish up the Scene, adding elements such as grass, clouds, and props. Remember to set the position with the Snap Settings tool, and set the priorities for the sprites.
- Set the Sorting Layers in the master Prefabs themselves in the _prefabs folder. This will ensure that all instances we add to our Scene carry them over.
- Let’s add some simple collision for our ground GameObjects. Select grassMid and grassCliffRight in the _prefabs folder.
- In the Inspector, click the Add Component button and select Physics 2D > Box Collider. This will add a Collider Component for our ground sprites that our Player GameObject will then be able to interact with.
- The colliders are added, but centered to the pivot of our GameObjects. We need to have the collision cover the bounds of the sprite. Make sure that grassMid and grassCliffRight are still selected from the _prefabs folder.
- Under the Box Collider Component, find the attribute for Center and set its values in X and Y to 0.5. This will move the collision to center exactly around our sprites.
- Don’t forget to save your Scene!
< Back
Page 7 of 7