[SCRIPT] How to create a sound trigger area? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] How to create a sound trigger area? (/thread-12250.html) |
How to create a sound trigger area? - Viuffuz - 01-01-2012 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. RE: How to create a sound trigger area? - BlueFury - 01-01-2012 I think it was: Code: void PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound); 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. RE: How to create a sound trigger area? - Statyk - 01-01-2012 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); } RE: How to create a sound trigger area? - eagledude4 - 01-01-2012 (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: make sure your void sound_func is outside onstart though. RE: How to create a sound trigger area? - Viuffuz - 01-03-2012 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); } RE: How to create a sound trigger area? - flamez3 - 01-03-2012 (01-03-2012, 08:22 AM)Viuffuz Wrote: hmmm.. What am I doing wrong?The script seems fine. Is the sound not playing? RE: How to create a sound trigger area? - Viuffuz - 01-03-2012 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!!! |