- Home /
Changing Continuous Audio Between Scenes
Hi, I'm trying to set up a continuous audio throughout my game. Normally I could just look at the many other questions related to this subject I've found online, but my problem is a bit different. To put it simply, in Scene 1, I want Track 1 to be playing. When I go to Scene 2, Track 1 stops and Track 2 begins to play. If I go from Scene 2 to Scene 3 or 4, Track 2 keeps playing as normal. If I at any point return to Scene 1, Track 1 resumes and Track 2 Stops. If I go to Scene 5, Track 3 begins to play and whatever track was currently playing stops.
The best way I can think of to do this would be to set up a permanent GameObject with a floating number. When I'm in scene 1, the Float is 1, Scene 2,3,4 the Float is 2 and Scene 5 the Float is 3. And then have the audio track change based on the number that is playing.
The main issue is that I've never actually worked with coding sound before, so I don't know how to make the audio play in the first place beyond checking off Play on Awake in the AudioSource component. Can anybody help me with this? Thank you in advance!