Hello,
This may be a somewhat odd question, but I have been fiddling with how I handle music and sound in my game, and at the moment I am curious as to what the best way to handle it in the below situation would be.
Let’s say I have two intergers, 10 and 20.
Whilst the whatever variable is between these two, I want X song to play. Once it either falls below or rises above my set points, I want it to fade out and play a new song.
The code ive set up for this is the most basic version of that, with it doing a hard check at what that variable currently is and then fading in and out based on it.
However, the issue comes with saving. As right now my code only checks if it passes those two points, not whether it plays the sound based on where the variable is NOW.
I have thought about saving the variable to my gamemode, and maybe running a loop or something to check what it is, and then if the variable stays the same, continue the song and change nothing, but with this I wonder if it is the most effective way or there is another one better.
To summarize, what is the most effective way to handle sound calls between two integer points? Can I have a sound passively play forever whilst its between them, and switch to another when it is not?
I appreciate any ideas that might come along.