- Home /
simple issue just need an expert/experienced advise AUDIO playback
hi all. apologies i'm very very novice so here it goes. i've scoured the net for a simple way to just play audio or even reference it. i have an mp3 file called "victory" that i need to play inside an if statement:
if (itemscorrect == 8){}
that's it. i just cant get any information on how i can reference victory.mp3 once this condition is met.
please help. thanks again
thanks.
https://docs.unity3d.com/ScriptReference/AudioSource.Play.html
Add an AudioSource component to your object in the scene and then make a script with the code shown in the link. You might need to configure it. Also, you can use it as an example when making it inside another script.
Answer by wh3resmycar · Oct 16, 2016 at 07:21 AM
ok I need further guidance. here's what I have
void update() {
if (GameLogic.ItemsCorrect == 8)
{
AudioSource audio = GetComponent<AudioSource>();
audio.Play();
audio.Play (44100);
}
}
}
I even tried it on void start but the music plays even if the condition is not met. any tips?
thanks.
Your answer
Follow this Question
Related Questions
MP3 corruption 2 Answers
help with multiple sounds 0 Answers
Audio doesn't play 1 Answer
NGUI Volume And Quality Controle With Sliders Not working 1 Answer
Play from a variety of sounds? 1 Answer