Quantcast
Channel: Answers for "How to change priority of audio clips"
Viewing all articles
Browse latest Browse all 4

Answer by aldonaletto

$
0
0
If these sounds are 3D, I suspect that you don't have to worry about this: according to [the docs][1], sounds that are less audible (the farthest ones) are occluded first when there are more AudioSources than available mixer inputs (priority is also taken into account). Anyway, I suppose that you could use a trigger to raise/lower the priority of each sound source: add or child a sphere trigger of the desired radius (range) to the player, and add also a kinematic rigidbody to it (moving triggers require a rigidbody, even kinematic), then place this code in every AudioSource: function OnTriggerEnter(other: Collider){ // audio source inside player range: audio.priority = 100; // set a higher priority } function OnTriggerExit(other: Collider){ // audio source out of player range: audio.priority = 128; // restore default priority } NOTE: Every object having one of these AudioSources must also have a collider in order to be detected by the trigger (rigidbody not required). [1]: http://docs.unity3d.com/Documentation/ScriptReference/AudioSource-priority.html

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>