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 now. However, in the previous chapter, we have written a function that allows the Panda to move by assigning its new position directly on its Transform. Since now the Panda has a Rigidbody2D component, we cannot do in this way anymore (as we already explained previously in the Rigidbodies section). Therefore, we need to slightly modify the PandaScript...