Help with GetComponent<AudioSource>().Play ();

Hi,

Would greatly appreciate it if someone told me how I can insert my audio source in this script:

GetComponent().Play ();

Do I need to have the sound file in my unity project and then simply insert its name? and between which brackets? An example would be great.

Thanks!

https://unity3d.com/learn/tutorials/modules/beginner/audio/audio-sources-and-listeners?playlist=17096
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/sound-effects-in-unity-5?playlist=17096

1 Like