How to Play Sound Effects in Unity

Objective: Play a sound during game play, for example when a powerup is collected.

First on the power up script I will need a reference to an audio clip.

I will add the serialized field attribute so I can assign an audio clip in the Inspector.

Next I will use the play clip at point function to play the audio clip when the Player collects the powerup. I have added the highlighted code to the OnTriggerEnter function.

This will play the audio at the location the power up was collected.

Happy Coding!!!