Game Sounds

Creating adayinit game audio zonesIn the zone
Today's weekend challenge was something I have been meaning to do for quite some time now.
The one thing I did not particularly care for was the ambient audio bleeding all over the place. I knew that this probably meant isolating zones, creating a script to control them, yada yada yada.... Well, today was that day. Pretty basic and not much thought around to the entire process. Creating zones would be the first step. Once the zones were established, I created a simple script that as you entered the zone, the script would stop the audio in all of the other zones and then play the audio "looped" in the zone you have entered. On exiting the zone, the script stops all of the zones. Creating adayinit game audio zones I would say the hardest part is to remember to enter the zone index on the zone.. heh. For some reason, this keeps escaping me as the main task to perform. I may reconsider a central list of zones so that I don't have to re-add the zone list every time I create a new audio zone, but for now this should do the trick. On first attempt in the home office, the zoning seemed to work as expected except for the collider being somewhat askew. I often struggle with colliders because they don't appear to land where I think I am setting them to during gameplay. As it turns out it was because I was using the collider as an actual collider and not a trigger. This mean that I was bumping into it physically. Checking the isTrigger checkbox means that you have passed into the space. On first attempt, when I set the zone to isTrigger, the audio stopped playing. This was because I was using OnColliderEnter instead of OnTriggerEnter... makes total sense because it is detecting the collision differently. You also have to switch the colliding object from Collision to Collider in the script, again makes sense because you are evaluating the collider, there is no actual collision. For example: OnTriggerEnter(Collider col) vs OnCollisionEnter(Collision col) or at least in my mind. Oh, and don't forget to set them as triggers, lest ye be falling through the map on impact.. lol. A very helpful collider vs trigger explanation is available here: https://www.codinblack.com/colliders-and-triggers-in-unity3d/