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
Script Help Trigger Sounds not working
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#1
Trigger Sounds not working

I'm trying to make it so when the player walks into an area, a sound plays but it's not working. Here's the script I'm using:

void OnStart()
{

AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("OpenDoor", "LevelKey1", "LevelDoor1", "UseKeyOnLevelDoor", true);
AddEntityCollideCallback("Player", "OpenScare", "SoundCheck", false, 1);
}



void SoundCheck(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("sound", "notice.snt", "OpenScare", 1.0f, false);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", "asEntity", 0, false);
RemoveItem(asItem);
}

void UseKeyOnLevelDoor(string &in asItem, string &in asEntity)
{

SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
void OnLeave()
{

}

Also, is there anything I have to do with the area besides the name?

The ones at the front always die first...
06-04-2016, 08:05 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#2
RE: Trigger Sounds not working

Is it a custom voice? Do you have the debug tool on?
06-04-2016, 09:31 PM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#3
RE: Trigger Sounds not working

It's one of amnesia's own sound files and I don't know where the debug tool is.

The ones at the front always die first...
06-04-2016, 09:43 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#4
RE: Trigger Sounds not working

(06-04-2016, 09:43 PM)Xallikk Wrote: It's one of amnesia's own sound files and I don't know where the debug tool is.

To enable the debug menu, go into your documents/Amnesia/Main and open up "main_settings.cfg". There find a line
PHP Code: (Select All)
LoadDebugMenu
and change it to "true". Now in-game you will be able to open up the debug menu (F1), which is of great help while building your custom story.

Regarding the issue: try changing
PHP Code: (Select All)
float afFadeTime 
in your function
Spoiler below!
[Image: ade4aca738594bf39082e6bb7a2a32c8.png]
into something like 0.1, or even 0.01. Your issue might occur because the sound you're trying to play is so short that the fade effect might actually "swallow" it.
(This post was last modified: 06-04-2016, 10:44 PM by Slanderous.)
06-04-2016, 10:44 PM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#5
RE: Trigger Sounds not working

There is still no sound. Is it perhaps because I have to put a PlayerInteractCallback on the script area in the editor or is that not needed?

The ones at the front always die first...
06-04-2016, 10:52 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#6
RE: Trigger Sounds not working

(06-04-2016, 10:52 PM)Xallikk Wrote: There is still no sound. Is it perhaps because I have to put a PlayerInteractCallback on the script area in the editor or is that not needed?

No, it's unnecessary. Try changing the source of the sound into "Player"
[Image: 6b6df4cc70bb447bb2c6372b81aa9ceb.png]
(This post was last modified: 06-04-2016, 10:55 PM by Slanderous.)
06-04-2016, 10:55 PM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#7
RE: Trigger Sounds not working

Still nothing although I noticed I hear a monster growl when I spawn in. It's not the same as the sound I chose, but it might be related?

The ones at the front always die first...
06-04-2016, 10:58 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#8
RE: Trigger Sounds not working

(06-04-2016, 10:58 PM)Xallikk Wrote: Still nothing although I noticed I hear a monster growl when I spawn in. It's not the same as the sound I chose, but it might be related?

.snt files usually contain several diffrent audio clips, thus they randomize which sound to play. The notice sounds in Amnesia usually look like this:

PHP Code: (Select All)
<SOUNDENTITY>
  <
SOUNDS>
      <
Main>
          <
Sound File="brute/notice01" />
          <
Sound File="brute/notice02" />
      </
Main>
  </
SOUNDS

You can see it by yourself by opening the .snt file in any text editor you're using. So in this case, using PlaySoundAtEntity will as I said randomize which sound to play among those 2.

If you want a particular sound to play, I reccomend using this function:
PHP Code: (Select All)
void PlayGuiSound(stringasSoundFilefloat afVolume);
Plays a soundnot using 3D.

asSoundFile the sound to play (extension is .snt)
afVolume the volume of the sound 

In GuiSound function, you just type in the name of the sound which you want to hear, for example "notice02.snt"
Make sure to have the .snt extension as well!
(This post was last modified: 06-04-2016, 11:06 PM by Slanderous.)
06-04-2016, 11:04 PM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#9
RE: Trigger Sounds not working

Well either one is fine, but that means it's playing on my spawn in to the map. How do I fix that?

The ones at the front always die first...
06-04-2016, 11:06 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#10
RE: Trigger Sounds not working

(06-04-2016, 11:06 PM)Xallikk Wrote: Well either one is fine, but that means it's playing on my spawn in to the map. How do I fix that?

Where is your "OpenScare" area? Is it located right where the player starts the map? If so, then that's the case of having the sound played at the spawn.
06-04-2016, 11:08 PM
Find




Users browsing this thread: 1 Guest(s)