O'Reilly logo

Unity 5.x Game Development Blueprints by John P. Doran

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating obstacles

Of course, the game wouldn't be fun without any challenges so we're going to add in the pipe-like obstacles that the player will also need to avoid.

  1. From the Art Assets folder, bring in the rockGrass and rockGrassDown sprite and place it into the Assets/Sprites folder from the Project tab.
  2. Drag and drop the rockGrass object into the world. Change its position to 0, -2.5, 0. Then, add a Polygon Collider 2D component to it.
  3. Afterwards, drag and drop the rockGrassDown object into the world. Change its position to 0, 2.5, 0. Then, add a Polygon Collider 2D component to it.
  4. Next, create an empty game object by selecting GameObject | Create Empty. Reset its position to 0,0,0 and then rename it to Obstacle. Afterwards, drag and drop the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required