Search Unity

Audio Can audio sources play more than one sound at a time? And another question.

Discussion in 'Audio & Video' started by RealMcCoyGames, Jul 16, 2021.

  1. RealMcCoyGames

    RealMcCoyGames

    Joined:
    Jul 23, 2018
    Posts:
    65
    So if I were to start an audio clip from an audio source, then swap the audio clip for another clip and play that, does the first clip just stop playing?

    If so could I just create a prefab with an audio source inside it. Then instantiate it wherever I want there to be a sound effect? Then delete it after it plays.
     
  2. itsfreshblood

    itsfreshblood

    Joined:
    Jul 22, 2021
    Posts:
    2
    You can attach several Audio Sources to the same GameObject in the Inspector, and get them to play at the same time by calling PlayOneShot(). You need the Audio Source attached to your main GameObject and then attach a script to the Audio Source. You can call the script to play multiple AudioClips in the following way:

    When you have created this script you will be able to drag your required AudioClips into the relevant script components.
     

    Attached Files:

    RealMcCoyGames likes this.