add sound effect to a random text string
Hi,
I scripted a dialogue with random answers between two possibilities. Thing is I want to add sound effect to those two strings, as in if string 0 do this, if string 1 do that. How can I do that? Here my script.
Thank you!
string[] texts = new string[] { "INGÉNIEURE ?", "CHIMISTE ?" };
public void ClickYes()
{
text.text = texts[Random.Range(0, texts.Length)];
}
Answer by UnbreakableOne · Jun 11, 2018 at 09:51 PM
Have an array/list of sound effects with the same length, so you would have two arrays with length of two. Call Random.Range and store the result. Use the integer you got from the Random.Range to get string from the "texts" array and sound effect from the sound effect array.
Thanks! I didn't do that exactly but you got me there :)
Your answer
Follow this Question
Related Questions
How to make an interactive movie (C#) 1 Answer
How can i use transform.position to a gameobject in an array? 1 Answer
Random.Range producing values outside its range. 1 Answer
changing the color of a random game object not working 0 Answers
Multiple instances of script generating the same random number 1 Answer