Jump to content
Sign in to follow this  
Janat

Can't get fadeMusic to work in a script

Recommended Posts

I can't get fadeMusic to work in a script. The script should first fade out any music track currently playing and then start playing a new track. Everything else works, but fadeMusic doesn't seem to do anything. The script has been compiled and preprocessed in init.sqf.

init.sqf

nextTrack = compile preprocessFile "nexttrack.sqf";

I call it via editor trigger

trigger activated field

[_next = "track", 3] spawn nextTrack;

If I use call instead of spawn, sleep command doesn't obviously work, else it works the same way as it does when spawning it. How can I get the script to work the way it should work? Here's the script:

nexttrack.sqf

private ["_musicTrack","_transitionLength"];

_transitionLength fadeMusic 0;

_musicTrack = _this select 0;
_transitionLength = _this select 1;

sleep _transitionLength + 2;

playMusic _musicTrack;

Share this post


Link to post
Share on other sites

I just changed the position of one line, it should work if you also add a fade in line (or volume remains at 0 level!!):

private ["_musicTrack","_transitionLength"];

_musicTrack = _this select 0;
_transitionLength = _this select 1;

_transitionLength fadeMusic 0;
sleep _transitionLength + 2;

_transitionLength fadeMusic 1;
playMusic _musicTrack;

Share this post


Link to post
Share on other sites

Thanks, wonder why the fade out doesn't work without fade in in this script... It does work everywhere else :confused:

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×