Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AudioSource Distance per Dimension

Discussion in 'Audio & Video' started by Zocker1996, Mar 28, 2016.

  1. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    I got layer based 2d mobile platformer. There are eagles on some layers and they perform an eagle sound. I want that sound to be heard only on the layer the eagle is flying.
    It would be helpfull if I could set the max distance for each dimension seperatly, since my layers are not quadradic (e.g. x 10 and y 3).
    Is that currently possible?

    If not, I think I'm going to use a collider as a trigger and as soon the player enters I will unmute the AudioSource.
    Any better suggestions?
     
  2. BarangerHolsnyder

    BarangerHolsnyder

    Joined:
    Sep 7, 2015
    Posts:
    13
    Hi,

    Colliders as triggers are a good solution (can also be coupled with audio mixer snapshots), or you could have one layer-audio-manager script which will handle all the muting/unmuting of all layers depending on where the player is at any given moment. Shouldn't be as resource-heavy as it sounds.
     
    Zocker1996 likes this.
  3. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    Yeah I guess your right, a central manager Script would be better i guess, its just an Iteration over all audiosources and a simple Check which should be more efficent then triggers. Thanks for the Suggestion ;)
     
  4. BarangerHolsnyder

    BarangerHolsnyder

    Joined:
    Sep 7, 2015
    Posts:
    13
    You're welcome. Happy Unitying !