Search Unity

Audio Question about PlayOneShot

Discussion in 'Audio & Video' started by PedroGV, Dec 11, 2018.

  1. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    When you use PlayOneShot for a clip using and existing instance of an AudioSource, will the clip respect the settings of that audio source (pitch, position, spatial blend, etc.)? Or will it use "default settings"?
     
  2. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    140
    Yes, it respects the Audio Source's settings.
     
    PedroGV likes this.
  3. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    @JLF: thanks for replying.

    What would happen if I take an audio source, set a position "1" (with a spatial blend greater to zero) play a shot of a clip, and then change the position (to "position 2"), and play another shot, while both clips are playing?

    Will the first clip continue to play on position "1"? Or position "2"?
     
  4. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    140
    I believe it would move with the Audio Source, but I've never tried it.

    Edit: I tried it and yes it moves with the Audio Source.
     
    cxode likes this.
  5. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    Thanks for trying it! So it would be safe to say that no hidden audio source is cloned from the main instance to play each new shot, right? (I'm thinking loud here)
     
  6. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    140
    That's right.

    When using PlayOneShot with multiple sounds the audio profiler reports only one Audio Source, no matter how many sounds you play through it.

    It's worth mentioning though that the sounds still contribute to the total voice count as normal, you're just saving on Audio Sources.
     
  7. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    I see. Besides the virtual and real sounds that the audio system can play, is there a count limit per audio source? 8, 16, 32, ..., that can be played at the same time by the audio source?
     
  8. JLF

    JLF

    Joined:
    Feb 25, 2013
    Posts:
    140
    Not that I'm aware of, just the global voice limits.
     
    PedroGV likes this.
  9. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    Thanks!
     
    JLF likes this.