How to play multiple sounds simultaneously

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…

You only need one Audio Listener, what you need is multiple AudioSources. You can play only one sound at a time per AudioSource, in order to play multiple sounds you need one AudioSource for each sound you want to play at the same time. You can have multiple GameObjects each one with its own AudioSource o have multiple AudioSources in one GameObject.

Hi everyone !

I’ve quite an issue very similar. I want to play several frequencies that I compute. For instance I want to play 150 Hz, 200Hz, and 322Hz at once. Playing a single frequency is very easy thank’s to this tutorial :

Unfortunately, this tutorial doesn’t work with multiple frequencies because we have to get several audio listenner which is impossible.

Have you any ideas doing this ?

Thank you :slight_smile: