Play audio clip
Hi i need help i am new to unity and coding and i dont know how do i make sound to play i am making quiz game and here is the script
public void UserSelectTrue() { animator.SetTrigger("True"); if (currentQuestion.isTrue) { Debug.Log("CORRECT!"); } else { Debug.Log("WRONG"); }
StartCoroutine(TransitionToNextQuestion());
}
I need help like when that code plays it plays the sound
sorry for bad english i am from finland
Thank you for helping :)
Answer by Jessespike · Jun 30, 2016 at 09:05 PM
Add an AudioSource component to the GameObject. Drop in a sound file to the AudioClip property.
In script, instruct the AudioSource to play.
public AudioSource audioSource;
....
audioSource.Play();
https://unity3d.com/learn/tutorials/topics/audio
https://docs.unity3d.com/ScriptReference/AudioSource.Play.html
Your answer
Follow this Question
Related Questions
Audio Clip Error. 2 Answers
Error FMOD::Sound instance - no sound is being played from AssetBundle 0 Answers
Audio won't play, no matter what code or method I try 0 Answers
Why won't my second Audio Source play? 0 Answers
Pick Up Sound 0 Answers