Home > Articles > Programming > Games

  • Print
  • + Share This
This chapter is from the book


  1. 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.
  2. 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.
  3. Let’s add some simple collision for our ground GameObjects. Select grassMid and grassCliffRight in the _prefabs folder.
  4. 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.
  5. 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.
  6. 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.
  7. Don’t forget to save your Scene!
  • + Share This
  • 🔖 Save To Your Account