In this section, we will configure the Cucumber Beetle prefab so that it supports audio when the Cucumber Beetles eat, when they run while standing, and when they die. Here are the steps:
- Select the beetle prefab in the Project panel's Assets | Prefabs folder. If you have more than one prefab, be sure to use the one that is used in your game.
- In the Inspector panel, scroll to the bottom and click the Add Component button.
- Select Audio | Audio Source.
- Uncheck the Play On Awake box.
Normally, we would assign an AudioClip to our Audio Source component. Since our Cucumber Beetles will have more than one audio clip, we will not assign one here.
Our next step is to edit the BeetleNPC script. Open that ...