Greven
Member
Posts: 106
Threads: 13
Joined: May 2011
Reputation:
3
|
Music in a certain area
Ok i need some help with music in a certain area. I have a big hall called castle halls which i want to have the soothing music while you are in this big hall. But the thing is it has many doors and level doors so im wondering how to make the music sound just in that hall.
Sorry for the nooby question :3
[WIP] Recidivus
(This post was last modified: 05-30-2011, 08:55 AM by Greven.)
|
|
05-28-2011, 08:25 PM |
|
laser50
Member
Posts: 242
Threads: 22
Joined: Apr 2011
Reputation:
0
|
RE: Music in a certain area
I think there was a Sound space. On the line where you can also pick entities and stuff.
Sorry i cannot tell more, I never used it.
|
|
05-28-2011, 08:55 PM |
|
xtron
Senior Member
Posts: 402
Threads: 37
Joined: May 2011
Reputation:
2
|
RE: Music in a certain area
If i get you correctly make a script and name it like "play_music_hall"
Then make a script with the function:
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
Dubstep <3
|
|
05-28-2011, 08:57 PM |
|
Greven
Member
Posts: 106
Threads: 13
Joined: May 2011
Reputation:
3
|
RE: Music in a certain area
(05-28-2011, 08:57 PM)xtron Wrote: If i get you correctly make a script and name it like "play_music_hall"
Then make a script with the function:
PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);
Thank you! :3
[WIP] Recidivus
|
|
05-28-2011, 09:25 PM |
|
xtron
Senior Member
Posts: 402
Threads: 37
Joined: May 2011
Reputation:
2
|
RE: Music in a certain area
Your welcome bud ^^
Dubstep <3
|
|
05-28-2011, 09:58 PM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Music in a certain area
You can use scripted collisions to control the music. Create an area that is as wide and long (height will not matter, as long as the player will walk through it) as the giant hall you are speaking of. Let's say you call it "grand_hall_area". In your OnStart() function put this:
AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);
Then create the MusicControl function like this:
void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(0, 2);
}
This way, whenever the player enters the area (when alState is 1), the music will begin. When the player exits the area (alState is -1), the music will stop with a fade time of two seconds.
|
|
05-29-2011, 10:28 AM |
|
Greven
Member
Posts: 106
Threads: 13
Joined: May 2011
Reputation:
3
|
RE: Music in a certain area
(05-29-2011, 10:28 AM)palistov Wrote: You can use scripted collisions to control the music. Create an area that is as wide and long (height will not matter, as long as the player will walk through it) as the giant hall you are speaking of. Let's say you call it "grand_hall_area". In your OnStart() function put this:
AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);
Then create the MusicControl function like this:
void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(0, 2);
}
This way, whenever the player enters the area (when alState is 1), the music will begin. When the player exits the area (alState is -1), the music will stop with a fade time of two seconds.
Um for me it doesnt work, so im wondering if that is the whole script? Oh and ive changed the soothingmusicfile.ogg to amb_09safe
[WIP] Recidivus
|
|
05-30-2011, 08:55 AM |
|
palistov
Posting Freak
Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation:
57
|
RE: Music in a certain area
Did you create the grand_hall_area? Also, I mixed up the numbers in StopMusic :X sorry!
The whole script will look like this
void OnStart()
{
AddEntityCollideCallback("Player", "grand_hall_area", "MusicControl", false, 0);
//more of your stuff here
}
void MusicControl(string &in asParent, string &in asChild, int alState)
{
if(alState == 1) PlayMusic("soothingmusicfile.ogg", true, 1.0f, 0, 0, true);
if(alState == -1) StopMusic(2, 0);
}
|
|
05-30-2011, 09:20 PM |
|
|