I've got a game when the user hits itself to the right or the left edge, there will be a sound, like oph, ouch, Oh No, and so on. I want that to be a random sound (random pick) each time.
here is the piece of code where we determine the sound name. In the following snippet hit1 is the sound name, one of them (as is determined in Elements). This code works well. The code comes from "controller.cs"
Note: Inside Unity there is an area in _Manager Prefab (_Manager/Audios Manager Script/Music Clips/Elements[Audio Clip, Sound Name, Volume]
) which this sound name and any other one is listed.
else
{
if (!iFly && !iJump)
{
animationManager.animationState = animationManager.TurnRight;
AudiosManager.instance.PlayingSound("hit1");
}
}
I've been trying to do it like this but it doesn't work by listing remaining sound names "hit1","hit2","hit3","hit4"
inside a Random (), like this Random("hit1","hit2","hit3","hit4")
hoping it works. But of course it didn't work.
Ok, here is how the code looks like now, which is not working.
else
{
if (!iFly && !iJump)
{
animationManager.animationState = animationManager.TurnRight;
AudiosManager.instance.PlayingSound(Random("hit1","hit2","hit3","hit4"));
}
}
To clarify, really the code responsible for this part is only this one AudiosManager.instance.PlayingSound("hit1");
. I could be wrong though.