Viuffuz
Junior Member
Posts: 13
Threads: 4
Joined: Jan 2012
Reputation:
0
|
How to create a sound trigger area?
I need help with creating an area that plays a sound only once when I enter that area for the first time.
I'd like to see a working example of that script. Thank you for your time.
|
|
01-01-2012, 06:49 PM |
|
BlueFury
Senior Member
Posts: 470
Threads: 30
Joined: May 2011
Reputation:
9
|
RE: How to create a sound trigger area?
I think it was:
void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
asSoundName - internal name
asSoundFile - the sound to use + extension .snt
asEntity - the entity to create the sound at, can be “Player”
afFadeTime - time in seconds the sound needs to fade
Correct me if i'm wrong.
Sticks and stones may break our bones, but words will break our hearts. – Robert Fulghum
(This post was last modified: 01-01-2012, 06:56 PM by BlueFury.)
|
|
01-01-2012, 06:51 PM |
|
Statyk
Schrödinger's Mod
Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation:
241
|
RE: How to create a sound trigger area?
continuing with BlueFury, try this. Make a script area where you would like the player to walk into to make the noise. Name it "soundarea" and try this:
//____________________
void OnStart()
{
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "SOUNDNAME.SNT", "OBJECT_WHERE_SOUND_OCCURS", 0, true);
}
|
|
01-01-2012, 07:58 PM |
|
eagledude4
Member
Posts: 144
Threads: 14
Joined: Dec 2011
Reputation:
0
|
RE: How to create a sound trigger area?
(01-01-2012, 07:58 PM)Statyk Wrote: continuing with BlueFury, try this. Make a script area where you would like the player to walk into to make the noise. Name it "soundarea" and try this:
//____________________
void OnStart()
{
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "SOUNDNAME.SNT", "OBJECT_WHERE_SOUND_OCCURS", 0, true);
}
make sure your void sound_func is outside onstart though.
Its hard to see the truth when you've been blinded by lies.
(This post was last modified: 01-01-2012, 09:00 PM by eagledude4.)
|
|
01-01-2012, 09:00 PM |
|
Viuffuz
Junior Member
Posts: 13
Threads: 4
Joined: Jan 2012
Reputation:
0
|
RE: How to create a sound trigger area?
hmmm.. What am I doing wrong?
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}
void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "level_wood_1", 0, true);
}
|
|
01-03-2012, 08:22 AM |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
RE: How to create a sound trigger area?
(01-03-2012, 08:22 AM)Viuffuz Wrote: hmmm.. What am I doing wrong?
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player", "soundarea", "sound_func", true, 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt_1" , true);
}
void sound_func(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "close_door.snt", "level_wood_1", 0, true);
} The script seems fine. Is the sound not playing?
|
|
01-03-2012, 08:36 AM |
|
Viuffuz
Junior Member
Posts: 13
Threads: 4
Joined: Jan 2012
Reputation:
0
|
RE: How to create a sound trigger area?
Yeah, I can't hear the sound... :/
Ahh now I got it guys I just had to restart the level editor and Amnesia! Thank you very much!!!
(This post was last modified: 01-03-2012, 12:55 PM by Viuffuz.)
|
|
01-03-2012, 12:53 PM |
|
|