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
Texture, Model & Animation Help Music "Lower" if player enters area
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#1
Music "Lower" if player enters area

I need to make it that if a people go into a certain area, the music's volume is getting lower, like form 1, it goes to 0.5 or something like that, and when he goes out of that area, the music will be back at 1.
Creating a snow map, and it can be much more realistic if the sound's turning lower if you're inside a building.
I don't really know how these If scripts work..
The only thing I can mind is
IF( blabla entitycollideare or idk, but is it possible to make the music's volume lower ??
(This post was last modified: 10-05-2015, 02:06 PM by Amnesiaplayer.)
10-03-2015, 06:00 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Music "Lower" if player enters area

If you set the music to Resume and then play the exact same music again with a lower volume, I believe that will do the trick.

Trying is the first step to success.
10-05-2015, 05:52 PM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#3
RE: Music "Lower" if player enters area

(10-05-2015, 05:52 PM)FlawlessHappiness Wrote: If you set the music to Resume and then play the exact same music again with a lower volume, I believe that will do the trick.

I did, but it doesn't matter, what volume I do, it stays at the same, O tried 0, 1, 3, 10....
Nothing works...
10-05-2015, 06:29 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Music "Lower" if player enters area

Running this:

PHP Code: (Select All)
PlayMusic("in_motion.ogg"false101true); 

Then later running this:

PHP Code: (Select All)
PlayMusic("in_motion.ogg"false0.212true); 

Achieves this effect. It starts the music at standard volume, then fades it down to 0.2.
I took this code from my Intro/Outro video, which shows the effect in action.

(This post was last modified: 10-05-2015, 07:01 PM by Mudbill.)
10-05-2015, 06:59 PM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#5
RE: Music "Lower" if player enters area

(10-05-2015, 06:59 PM)Mudbill Wrote: Running this:

PHP Code: (Select All)
PlayMusic("in_motion.ogg"false101true); 

Then later running this:

PHP Code: (Select All)
PlayMusic("in_motion.ogg"false0.212true); 

Achieves this effect. It starts the music at standard volume, then fades it down to 0.2.
I took this code from my Intro/Outro video, which shows the effect in action.

I know that, and I did that.
but the sound is staying at the same volume, maybe something is wrong with my music snt file?!

PHP Code: (Select All)
<SOUNDENTITY>
  <
SOUNDS>
      <
Main>
          <
Sound File="SnowStorm" />
      </
Main>
  </
SOUNDS>
  <
PROPERTIES Volume="0.5" MinDistance="20" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="True" Loop="True" Use3D="False" Blockable="False" BlockVolumeMul="0.5" Priority="0" />
</
SOUNDENTITY

Btw, if it would work, how am I supposed to do the "IF" thing?
I tried some things but couldn't end up at the thing I wanted to end,
so basically, If the player is inside of an AREA, the "void" will start, so basically, the music will be lower, and if the player leaves the area, the other thing will happen, which makes the music at the normal state...
I know most of the scripting but this one is a little bit weird to me...
10-06-2015, 06:04 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Music "Lower" if player enters area

The last number in the AddEntityCollideCallback, int alStates.

PHP Code: (Select All)
AddEntityCollideCallback(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates); 

If you set it to 0, the callback calls both when entering and when leaving the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""Area""Function"false0); 

In your function you would then do:

PHP Code: (Select All)
void Function(string &in asParentstring &in asChildint alState)
{
if(
alState == 1//If entering
{
//Do stuff if entering
}

if(
alState == -1//If leaving
{
//Do stuff if leaving the area
}


Trying is the first step to success.
(This post was last modified: 10-06-2015, 08:10 PM by FlawlessHappiness.)
10-06-2015, 08:09 PM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#7
RE: Music "Lower" if player enters area

(10-06-2015, 08:09 PM)FlawlessHappiness Wrote: The last number in the AddEntityCollideCallback, int alStates.

PHP Code: (Select All)
AddEntityCollideCallback(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates); 

If you set it to 0, the callback calls both when entering and when leaving the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""Area""Function"false0); 

In your function you would then do:

PHP Code: (Select All)
void Function(string &in asParentstring &in asChildint alState)
{
if(
alState == 1//If entering
{
//Do stuff if entering
}

if(
alState == -1//If leaving
{
//Do stuff if leaving the area
}


Thanks!! Now this is solved, I tried it, and it worked, now I can upgrade more old scriptings haha.
But now about the music, is there something wrong with my snt file?! since it doesn't change from volumes or doesn't "fade" to a lower volume...
10-07-2015, 12:52 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#8
RE: Music "Lower" if player enters area

Show the script where you tried it.

Trying is the first step to success.
10-07-2015, 03:01 PM
Find
Amnesiaplayer Offline
Senior Member

Posts: 539
Threads: 105
Joined: Jun 2014
Reputation: 0
#9
RE: Music "Lower" if player enters area

(10-07-2015, 03:01 PM)FlawlessHappiness Wrote: Show the script where you tried it.

PHP Code: (Select All)
{
PlayMusic("SnowStorm"true101true);
AddEntityCollideCallback("Player""Area115""MoveGround"true0);
AddEntityCollideCallback("Player""SlowDown""Slower"false0);
AddEntityCollideCallback("Player""Slow2""Slower2"false0);
AddEntityCollideCallback("Player""Mlow""Lower"false0);
SetMessage("Messages""Perspective2"2);
}

void Lower(string &in asParentstring &in asChildint alState)
{
if(
alState == 1)

PlayGuiSound("quest_completed"5);
PlayMusic("SnowStorm"true0.512true);
}

if(
alState == -1)
{
PlayMusic("SnowStorm"true101true);
}

10-07-2015, 06:19 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#10
RE: Music "Lower" if player enters area

The issue might be your priority. Remember that the priority must be higher than the currently music playing if you want it to override. If it isn't, nothing will happen.
Also, since this script runs multiple times, I think you need to create an ever-increasing value for it, unless you stop the previous (though this might disrupt the flow).

PHP Code: (Select All)
void OnStart()
{
    
PlayMusic("SnowStorm"true101true); //prio 1
    
AddEntityCollideCallback("Player""Mlow""Lower"false0);
    
SetLocalVarInt("MusicPrio"1); //set priority variable to 1
}

void Lower(string &in asParentstring &in asChildint alState)
{
    
AddLocalVarInt("MusicPrio"1); //add to the variable every time this code runs

    
if(alState == 1//entering area
    

        
PlayGuiSound("quest_completed"5);
        
PlayMusic("SnowStorm"true0.51GetLocalVarInt("MusicPrio"), true); //sets priority higher than before.
    
}

    if(
alState == -1//exiting area
    
{
        
PlayMusic("SnowStorm"true10GetLocalVarInt("MusicPrio"), true); //sets priority even higher because the AddLocalVarInt has now run once again.
    
}


Hope this makes sense. If I understand you correctly, you want this to keep turning up or down in volume as you enter this area. If you only want it to happen once each time, then the variable is unnecessary. If that's the case, just make the last one 3 instead of 1.

(This post was last modified: 10-07-2015, 07:05 PM by Mudbill.)
10-07-2015, 07:05 PM
Find




Users browsing this thread: 1 Guest(s)