Changing Music during gameplay
3absh
Member Posts: 601
At certain conditions I want a different track to play.
I'm trying to make previous music fade out (Audio.Music.volume interpolates to zero) then the new one starts, instead of an instant cutoff of music. This is what I did but it doesn't seem to work
Comments
Put the music before the change attribute or interpolate it back up.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
What, specifically, does 'doesn't seem to work' mean in this context ?
The second part, basically the music fades out but I don't think the part under "timer" is working.
I think you are coming in too soon at the end of the interpolate, even if the interpolate takes a single code cycle longer than 1 second to finish (for example 1.0166666666) it will defeat the change-attribute-music-volume-to-1.
Try chaining the timer from After 1 seconds to something like After 1.02 seconds, if that doesn't work try a slightly longer time.
Maybe after the interpolate he should have a stop music behavior and then he knows the other track is stopped. I would also do a quick fade up instead of the change attribute. This will give the second track a moment to fire. I would make the fade up .03 which should be right at the next cycle full volume.
Interpolate music volume
Rule
When game.audio.music.volume = 0
Stop music
After 1 second
Interpolate music volume .03 sec
Play music
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I changed it to 1.1 and it worked!!!!
Thanks Socks as always
From now on I really need to rethink timers, I think these sort of solutions require experience more than logic.
Yes you need to think in terms of the code scan in relation to time
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Agreed, code scan, code cycle, draw cycles, frame rate, call it what you will, it's probably a good thing to have in mind when dealing with these issues.
Good !