There's more...

In our example, the character will die whenever it touches the spikes of our trap. We can add some more realism by using Animation Events to enable the triggers when the trap is closing and disable them when it opens. It would prevent us from killing the character when the trap is not closing on them. You can learn more about Animation Events in Chapter 6Handling Combat.

Remember that you can also rotate the triggers, similar to how we did it in the Using the Hierarchy to animate local rotation - creating an orbiting planet recipe. Scaling the triggers is also possible.

You should not use this concept for moving normal colliders. Always try to use a Rigid body set to Is Kinematic when you want to move a collider (for optimization reasons).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.69.199