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

Answer by chaguaramo

$
0
0
Hi, with this script I can create audio zones with a random form that are on while the rest of my audio sources are turned off. So I could reduced the numbers of audio sources playing simultaneously. Thanks to Daniel Murcia! For use it, create a surface with the form you need and place it on the floor level, add a mesh collider, select-on the is trigger option, unselect the mesh render option and attach to the surface you have created the audio sources you want to be played simultaneously when enter in the zone designed by your surface. So you can differentiate audio zones that are played at once when they are triggered. #pragma strict var audioSources; function Start(){ audioSources = gameObject.GetComponentsInChildren(AudioSource); } function OnTriggerExit(){ Debug.Log("stopping sounds"); Debug.Log(this); var self = this; for (var source:AudioSource in audioSources) { Debug.Log(source); source.Stop(); } } function OnTriggerEnter(){ Debug.Log("starting sounds"); Debug.Log(this); var self = this; for (var source:AudioSource in audioSources) { Debug.Log(source); source.Play(); } }

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images

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