Detecting collisions
As you can see, proper Physics settings can be complicated and very important, but now that we have tackled that, let's do something with those settings by reacting to the contact in different ways and creating a Health System in the process.
In this section, we will examine the following collision concepts:
- Detecting Trigger events
- Modifying the other Object
First, we are going to explore the different collision and trigger events Unity offers to react to contact between two Objects through the Unity collision events. This allows us to execute any reaction code we want to place, but we are going to explore how to modify the contacted Object components using the GetComponent
function.
Detecting Trigger events
If Objects are properly configured, as previously discussed, we can get two reactions, triggers and collisions. The Collision reaction has a default effect that is blocking the movement of the Objects, but we can add custom...