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 Unity's collision events. This will allow us to execute any reaction code we want to place. However, here, we are going to explore how to modify the contacted Object components using the GetComponent
function.
Detecting Trigger events
If objects have been configured properly, as we previously discussed, we can get two reactions: triggers and collisions. The Collision reaction has a default effect that blocks the movement of the Objects...