Question by
james_licarte · Sep 10, 2017 at 09:38 AM ·
audioaudiosourceaudioclip
How to play audio base on a variable, what am i missing here?
I'm trying to play an audio that loops base on a variable, please help
ask-unity.png
(25.1 kB)
Comment
Answer by yanivng · Sep 10, 2017 at 09:56 AM
You are calling "audio.Play()" every frame. This is not what you meant to do. Try to change the value of trigger inside your if statement so it is not called in the next frame. In addition, you should set the volume of the audio source (_audio.volume = 1f or whatever).
Answer by james_licarte · Sep 10, 2017 at 11:06 AM
I am still getting this errors. I have applied all the things you told me. I changed the trigger to "off" when it enters the if statement. However I'm still having this problem that maybe causing why it won't play.
here's for my c# soundeffect script
ask-unity3.png
(5.5 kB)
ask-unity2.png
(7.2 kB)