Xallikk
Junior Member
Posts: 35
Threads: 7
Joined: Jun 2016
Reputation:
0
|
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 |
|
Slanderous
Posting Freak
Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation:
63
|
RE: Trigger Sounds not working
Is it a custom voice? Do you have the debug tool on?
|
|
06-04-2016, 09:31 PM |
|
Xallikk
Junior Member
Posts: 35
Threads: 7
Joined: Jun 2016
Reputation:
0
|
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 |
|
Slanderous
Posting Freak
Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation:
63
|
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 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 in your function
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 |
|
Xallikk
Junior Member
Posts: 35
Threads: 7
Joined: Jun 2016
Reputation:
0
|
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 |
|
Slanderous
Posting Freak
Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation:
63
|
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"
(This post was last modified: 06-04-2016, 10:55 PM by Slanderous.)
|
|
06-04-2016, 10:55 PM |
|
Xallikk
Junior Member
Posts: 35
Threads: 7
Joined: Jun 2016
Reputation:
0
|
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 |
|
Slanderous
Posting Freak
Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation:
63
|
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:
<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:
void PlayGuiSound(string& asSoundFile, float afVolume); Plays a sound, not 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 |
|
Xallikk
Junior Member
Posts: 35
Threads: 7
Joined: Jun 2016
Reputation:
0
|
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 |
|
Slanderous
Posting Freak
Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation:
63
|
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 |
|
|