OnTriggerEnter/Exit for different music zones in level. Plays music for only one zone.
Hey, I'm creating a 2D game for my major project. And I'm trying to get different ambient tracks to play in each part of the level/scene. I've attached the script to an empty gameObject, which has an AudioSource, and a BoxCollider2D set as a trigger.
When the gameObject detects the player via it's Tag (the "Player" Tag). It'll fade in the ambient track attached to the AudioSource on the gameObject. And it'll do the same when it detects the Player leaves but in reverse.
I've created the fades using the animator, and turning the volume of the audio component up or down. It's a quick and super easy way of doing a fade.
And I have 4 of these "zones" within the level/scene.
My problem is It'll play the first zone I enter the Player in and out seamlessly. But when I try going into the other "zones". I can see the fade animation play when the Player enters, and Exits but the AudioSource will not play the attached ambient track attached to the other AudioSource components, on the other gameObjects.
Does it have to do with Unity only allowing one audio source at a time?
Also I hope I'm not stepping on anybody's toes. And I hoe I explained it well enough. I'm relatively new to the concept of asking for help on here. If you guys need any further information, please let me know.
Here is what the script looks like I've got attached to them. This one is for Zone 4. I need all 4 zones to play when the player enters and exits them. but at the moment, only the first zone the player enters will play with a fade, and exit with a fade.
Thank you guys in advance.
Your answer
Follow this Question
Related Questions
Audio source is playing everywhere 0 Answers
Audio Source not loaded attached with prefab 0 Answers
Several music tracks on camera controlled by AudioSource.mute 1 Answer
Sound bug - Emergency HELP 0 Answers