Play Audio Sound On Left Click ("Fire1")

Hello, i am very new to Unity and have successfully made a first person slashing animation that triggers when i press (“Fire1”) and moves along with a first person controller. Could somebody please give me instructions on how to attach an audio file, (called “Swoosh”) to my character and give me a c# line of code for it to play when i press (“Fire1”)

Thank you!

I’ll do you one better and point you to the Unity sound tutorials.

Audio Listeners and Sources

Here’s the audio section of Unity’s Space Shooter tutorial project. It explains in detail exactly what to do, and has sample code.

To add to what Dave posted, if you want to play the sound at a specific time of your animation you can use an event: http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html

attach an audio source to player,drag your file to audiosource then write this code under fire button press

gameObject.audio.Play();