Game Development Reference
In-Depth Information
Figure 4-10. Adding a Physics Collider to the Cash Power-Up to detect collisions with the Player
Now the object is almost configured for collision detection with the Player. There's still one more
step. For this object, and all power-ups, we want Unity to notify us explicitly in the script as and
when collisions occur between the Player and Power-Ups, so we can respond appropriately, such as
by removing the power-up object from the scene and increasing the collected cash score. Right now,
Unity won't notify us by default. But we can easily configure the collider to do so. Just enable the Is
Trigger check box from the Collider component in the Object Inspector. Enabling this will force Unity
to send an event notification (a function call) to all components on the object whenever a collision
occurs, if any (see Figure 4-11 ).
Figure 4-11. Enable “Is Trigger” to receive collision notifications in the script when collisions happen
Search WWH ::




Custom Search