I am creating a 3d endless runner game. I am unable to play multiple sounds at the same time. What I want is to play a sound in the background through out the game that will be stopped when the game overs. When the Horse Rider jumps then play a sound for jump once, When the horse rider changes the lanes then play a sound for changing the lane. When the horse moves forward play a sound for the footsteps as well. Now here i am confused with the audio listeners that how many audio listeners will I be needing? how to play multiple sounds at the same time. Please guide me about this.
Following is my code :
public AudioClip mysound;
private AudioSource source;
public AudioClip collision_sound;
void update ()
{
if (!source.isPlaying) {
source.clip = mysound;
source.Play ();
}
}
public void OnCollisionEnter(Collision collision) {
source.Stop();
source.clip=collision_sound;
source.Play();
}
After this the background sound continues to play…