Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
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 |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Music "Lower" if player enters area
Running this:
PlayMusic("in_motion.ogg", false, 1, 0, 1, true);
Then later running this:
PlayMusic("in_motion.ogg", false, 0.2, 1, 2, true);
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 |
|
Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
RE: Music "Lower" if player enters area
(10-05-2015, 06:59 PM)Mudbill Wrote: Running this:
PlayMusic("in_motion.ogg", false, 1, 0, 1, true);
Then later running this:
PlayMusic("in_motion.ogg", false, 0.2, 1, 2, true);
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?!
<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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Music "Lower" if player enters area
The last number in the AddEntityCollideCallback, int alStates.
AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
If you set it to 0, the callback calls both when entering and when leaving the area.
AddEntityCollideCallback("Player", "Area", "Function", false, 0);
In your function you would then do:
void Function(string &in asParent, string &in asChild, int 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.
|
|
10-06-2015, 08:09 PM |
|
Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
RE: Music "Lower" if player enters area
(10-06-2015, 08:09 PM)FlawlessHappiness Wrote: The last number in the AddEntityCollideCallback, int alStates.
AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
If you set it to 0, the callback calls both when entering and when leaving the area.
AddEntityCollideCallback("Player", "Area", "Function", false, 0);
In your function you would then do:
void Function(string &in asParent, string &in asChild, int 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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Amnesiaplayer
Senior Member
Posts: 539
Threads: 105
Joined: Jun 2014
Reputation:
0
|
RE: Music "Lower" if player enters area
(10-07-2015, 03:01 PM)FlawlessHappiness Wrote: Show the script where you tried it.
{ PlayMusic("SnowStorm", true, 1, 0, 1, true); AddEntityCollideCallback("Player", "Area115", "MoveGround", true, 0); AddEntityCollideCallback("Player", "SlowDown", "Slower", false, 0); AddEntityCollideCallback("Player", "Slow2", "Slower2", false, 0); AddEntityCollideCallback("Player", "Mlow", "Lower", false, 0); SetMessage("Messages", "Perspective2", 2); }
void Lower(string &in asParent, string &in asChild, int alState) { if(alState == 1) { PlayGuiSound("quest_completed", 5); PlayMusic("SnowStorm", true, 0.5, 1, 2, true); }
if(alState == -1) { PlayMusic("SnowStorm", true, 1, 0, 1, true); } }
|
|
10-07-2015, 06:19 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
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).
void OnStart() { PlayMusic("SnowStorm", true, 1, 0, 1, true); //prio 1 AddEntityCollideCallback("Player", "Mlow", "Lower", false, 0); SetLocalVarInt("MusicPrio", 1); //set priority variable to 1 }
void Lower(string &in asParent, string &in asChild, int alState) { AddLocalVarInt("MusicPrio", 1); //add to the variable every time this code runs
if(alState == 1) //entering area { PlayGuiSound("quest_completed", 5); PlayMusic("SnowStorm", true, 0.5, 1, GetLocalVarInt("MusicPrio"), true); //sets priority higher than before. }
if(alState == -1) //exiting area { PlayMusic("SnowStorm", true, 1, 0, GetLocalVarInt("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 |
|
|