Detecting collisions
As you can see, proper physics settings can be complicated and very important, but now that we have tackled that, let’s perform some tasks with those settings by reacting to the contact in different ways, 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 us to react to contact between two objects, through Unity collision events. This allows us to execute any reaction code we want to place, but here, 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: collisions or triggers. The Collision reaction has a default effect that blocks the movement of the objects, but we...