Physics for our game
In this section we will apply some concepts of this chapter into our game. In particular, we will see how to detect when a sprinkle hits a panda and applies damage to it using the Physics engine.
Set up Pandas as a rigidbodies
Since we will take advantage of the Physics engine, we need to proper set up the Panda as that to be a physical object in the scene. This means giving it a rigidbody component.
Therefore, we can start by adding a Rigidbody2D component to the Panda prefab, and set its Body Type as Kinematic, as shown in the following screenshot:
In theory, we should have done, since the Panda is considered a physical object ...
Get Getting Started with Unity 5.x 2D Game Development 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.