Prototype 2: Mission Demolition

Physics games are some of the most popular around, making games like Angry Birds household names. In this chapter, you make your own physics game that is inspired by Angry Birds and all the physics games, such as the board game Crossbows and Catapults, that came before it.

This chapter covers the following: physics, collision, mouse interaction, levels, and game state management.


  • p. 479 – See note below about changes to GUIText in Unity 4.6.
  • p.479 – The text of bullet point 6 reads “Create a second GUIText and name it GT_Shots.” This should be GT_Score.


Unity 4.6 and Unity 5.x Update Deprecating GUIText

With the release of Unity 4.6 came major changes to the GUI (Graphical User Interface) within Unity. This process has continued, and now in Unity 5.4, they have completely deprecated the use of the old immediate mode GUI system. Now, I recommend using the much more robust UGUI (Unity Graphical User Interface) system and have described how to incorporate it into the projects in the first edition of the book here.


Issue with Castles Falling Down On Their Own

You may have noticed your castle falling apart before you hit it with anything. This seems to be due to a small change in the physics engine that happened since I wrote the book. Here’s how to fix it:

From the menu, go to Edit > Project Settings > Physics. This is the same place that you set which physics layers collide with each other. The option Sleep Threshold has a default value of 0.005. The sleep threshold is the minimum movement that something must have to be considered “awake” by the PhysX engine. Once something moves less than 0.005 m/s, it is considered asleep, and PhysX stops thinking about it. Somehow, this is too low for castles on some machines and causes issues. If you change Sleep Threshold to 0.01, it should fix the issue.


Unity 5 Update

Unity made a few changes to their C# code for Unity 5. The PDF below contains full code listings for the FollowCam.cs, Goal.cs, ProjectileLine.cs, and Slingshot.cs code files, which all require small changes due to Unity 5. These few changes are all highlighted in yellow in the code listings.


Lecture Notes


Tutorial Files