Table of Contents
Before engaging this section, please complete the parent section - Trigger Conditions.
When a Trigger has been added to a game object, it will report all encounters with other Triggers and Colliders to the AkTriggerEnter function. This means that unless you specify what type of Colliders or Triggers you are looking for, a game objects like the 301_Coin will play the Pickup_Coin Event for every other intersecting Trigger, and not only when the player is entering the Trigger to pick it up. One way to solve this, is by adding a AkTriggerEnter script to the 301_Coin game object.
When you've set an AkEvent to AkTriggerEnter, the AkEvent will look for a AkTriggerEnter script on starting the game.
In the AkTriggerEnter component you'll find a Trigger Object property. If the property is empty, it will listen to each and every collision. By adding a game object to this property, you will restrict the component to only react to that specific game object, thereby ignoring all other game objects.
The AkTriggerEnter's Trigger Object cannot be assigned with game objects from a different Scene. If you need that in your own game, one method would be to make a custom script and find the game object once it's available.
Let's now add the AkTriggerEnter script to the Coin, so it will only trigger when the Player is picking it up.
In the Hierarchy, select the 301_Coin game object.
In the Inspector, click Add Component.
Search for 'AkTriggerEnter' and select it.
In the AkTriggerEnter component, look for the empty Trigger Object property. As the Adventurer is the one doing all the hard work of picking up items, let's choose the Player. Without populating the Trigger Object property, all game objects will be detected.
In the Hierarchy, click and hold the Player game object and drag it into the Inspector > AkTriggerEnter component > Trigger Object property.
Click Play and pick up the Coin.
Notice that the Coin pickup sound is only posted when the player is picking up the Coin.
Press ESC to open the WAG menu and click Play again to exit Play mode.