Frictional Games Forum (read-only)

Full Version: How to stop music playing?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I'm having a problem with my script to play music. I have six levels and in the first one, there's a script that starts music. When entering the second level, there is a script to stop music.

The code is as follows:
Code:
void OnEnter(){     PlayMusic("02_amb_strange.ogg",true ,0.4f,0.2f,1,false);}


On the next level, I have a statement that should stop the music from playing which is as follows:
Code:
void OnEnter(){    StopMusic(2.0f,0);}


However, there is a problem. When I enter the second level, the music continues to play. On the last 3 levels, the music is supposed to stop but it doesn't on any of them. I've tried putting StopMusic statements in 'OnLeave' in addition and that doesn't work.

Is there something I'm missing?
To stop the music you can just put StopMusic in OnLeave() and also to stop the music you need to have the same priority on both. You have priority 1 on PlayMusic then you also need Priority 1 on StopMusic Smile
Ah it works both ways now - It was just the priority, haha I can't believe that was all.

Thanks for your help SilentStriker!
Your welcome Smile

Welcome to the forum Smile