Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Music Replaying In Different Levels?
dailycreepypasta Offline
Junior Member

Posts: 32
Threads: 18
Joined: Aug 2014
Reputation: 0
#1
Music Replaying In Different Levels?

I've been recently trying to test out my custom story, and I have music in one certain level that plays just fine in the level that I put it in, but when I try going to different maps, the music continues playing in that level. I don't know if it's my computer or not, but I don't want that happening when I release it, Pleas help?

Creator of "The Night I Went Insane".

http://www.moddb.com/mods/the-night-i-went-insane
04-05-2015, 12:01 PM
Find Reply
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#2
RE: Music Replaying In Different Levels?

In every level's script add this function:

PHP Code: (Select All)
void OnEnter()
{
    
StopMusic1);
    
StopMusic1);
    
StopMusic1);
    
    
StopPlayerLookAt();
    
ChangePlayerStateToNormal();
    


The first three lines stops the music of priority 0,1 and 2.
StopPlayerLookAt() stops the camera in case the previous level called a StartPlayerLookAt() and couldn't end it.
Then, ChangePlayerStateToNormal(); resets some stats, but I don't remember why I put this here, but it stops strange behavior brought from the previous level.

04-05-2015, 01:05 PM
Find Reply
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Music Replaying In Different Levels?

...That depends on if you want to stop certain things.

At least, StopMusic stops the music in OnEnter.
If you don't want it to stop in a certain level just remove StopMusic.

Trying is the first step to success.
04-05-2015, 01:53 PM
Find Reply
Darkfire Offline
Senior Member

Posts: 366
Threads: 21
Joined: May 2014
Reputation: 15
#4
RE: Music Replaying In Different Levels?

Why do it like this ?
I always do this:
OnEnter
{
StartMusic(yaddda yadda, 1) <---priority of music is important
}

OnLeave
{
StopMusic(yadda yadda, 1)
}

04-05-2015, 03:24 PM
Find Reply
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Music Replaying In Different Levels?

That's also a way.
There's no real way to do it.
As long as you understand StopMusic stops the music, you can decide on your own wherever you want it.

Trying is the first step to success.
(This post was last modified: 04-05-2015, 04:35 PM by FlawlessHappiness.)
04-05-2015, 04:35 PM
Find Reply




Users browsing this thread: 1 Guest(s)