Change the music clip when crossing a cube border ?

Hello.

I have really stuck on the follow issue:

  • How to change the AudioSource clip when i am crossing trough a big box border ?

Here’s a tutorial on trigger zones. It even has code to get you started.

Basically what you want is a box collider (you can have it on a cube if you want so you can see it during editing, but you most likely want to turn the renderer off for the game… unless you want to see the box you are crossing into) and set the collider “is trigger” to true.

Is trigger will prevent it from acting like a physical box that stops you, but will still fire off a collision event (one specific for trigger called “OnTriggerEnter”).

You’ll still need to add your own code for checking it’s the character that is coming into the border (or camera or whatever goes beyond the box border) then you simply play your audiosource clip (stopping your other one if need be… various ways to do that depending on how you have your project set up).