Hi ; I am beginner in unity . I want to play a sound which it is in 'Sounds' folder in assets . I tried this code : Code (csharp): audio.Play(kick2); but I got this error : Unknown Identifier 'kick2' I don't know how to address to find it in Sound folder . I tried these syntaxes but I got error too . audio.Play(My Assets/Sounds/kick2) and audio.Play('My Assetes/Sounds/kick2') and ... Please say the correct syntax ... thanx
What you want to do is create a variable that will hold your sound "Kick2" Like this Code (csharp): public var kick2 : AudioClip; public function PlaySound() { Audio.Play(kick2); { C# version Code (csharp): public AudioClip kick2; public void PlayAudioClip() { Audio.Play(kick2); }
Thank you , But I got this error : BCE0017: The best overload for the method 'UnityEngine.AudioSource.Play()' is not compatible with the argument list '(UnityEngine.AudioClip)'.