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
Adding a Sound Triggered by an Area
Samuelblitz Offline
Junior Member

Posts: 16
Threads: 4
Joined: Feb 2011
Reputation: 0
#1
Adding a Sound Triggered by an Area

Hello everyone, i'm pretty new to scripting / amnesia editing in general and there's one thing im confused about right now.

I have a fairly basic map set up right now with some basic scripts being used, and i realized i wanted to add some noises to my environment

So far i have tried these methods:

- Placing a "Sound" from within the level editor. (No matter how much i tweaked the sound's settings, i could never hear it in-game)

- Creating a script area in the level editor, and then scripting a collidecallback so that it would play a sound from a nearby entity.

This is what my script looked like:

void OnStart()
{
AddEntityCollideCallback("Player", "monsterscare1", "CollideAreaTest01", true, 1);

}

void CollideAreaTest01(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "enabled.snt", "sloped_square_shelf_1", 6.0f, false);

AddDebugMessage("Entered area!", false);

}


Thanks in advance to anyone that can help!
03-01-2011, 12:48 AM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#2
RE: Adding a Sound Triggered by an Area

You could try adding a sound entity near the shelf and make it play the .snt you want it to. Then just change the "sloped_square_shelf_1" to "sound_1", as maybe the origin of sound might be muffled from the shelf.
03-01-2011, 02:39 AM
Find
Samuelblitz Offline
Junior Member

Posts: 16
Threads: 4
Joined: Feb 2011
Reputation: 0
#3
RE: Adding a Sound Triggered by an Area

(03-01-2011, 02:39 AM)Russ Money Wrote: You could try adding a sound entity near the shelf and make it play the .snt you want it to. Then just change the "sloped_square_shelf_1" to "sound_1", as maybe the origin of sound might be muffled from the shelf.

thank you for your help!

I did exactly as you said and it partially worked

this time my game actually displayed the debug text it is supposed to when i walk into the area, except still no sound, and i have no idea why
03-01-2011, 03:55 AM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#4
RE: Adding a Sound Triggered by an Area

Which sound .snt are trying to use specifically? Also, maybe try changing the fade to something quicker than six seconds, try

PlaySoundAtEntity("", "enabled.snt", "sound_1", 1.0f, false);
(This post was last modified: 03-01-2011, 04:01 AM by Russ Money.)
03-01-2011, 04:01 AM
Find
Samuelblitz Offline
Junior Member

Posts: 16
Threads: 4
Joined: Feb 2011
Reputation: 0
#5
RE: Adding a Sound Triggered by an Area

(03-01-2011, 04:01 AM)Russ Money Wrote: Which sound .snt are trying to use specifically? Also, maybe try changing the fade to something quicker than six seconds, try

PlaySoundAtEntity("", "enabled.snt", "sound_1", 1.0f, false);

enabled.snt is one of the grunt's sound files and i tried the fade at 0.0f but still no sound in-game,

just out of curiosity, is this a common problem? or is it just my game specifically?
03-01-2011, 09:43 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#6
RE: Adding a Sound Triggered by an Area

Quote:enabled.snt is one of the grunt's sound files and i tried the fade at 0.0f but still no sound in-game,

just out of curiosity, is this a common problem? or is it just my game specifically?

Most likely just a coding or some small detail we're overlooking. Just for testing sake, try this instead.


PlaySoundAtEntity("", "enabled.snt", "Player", 0.0f, false);

It'll play directly on the player, letting them hear it regardless. If it doesn't play, it's .snt file. Which alternatively, you can try a different .snt and test that.
(This post was last modified: 03-02-2011, 08:17 AM by Russ Money.)
03-02-2011, 08:17 AM
Find
Samuelblitz Offline
Junior Member

Posts: 16
Threads: 4
Joined: Feb 2011
Reputation: 0
#7
RE: Adding a Sound Triggered by an Area

(03-02-2011, 08:17 AM)Russ Money Wrote:
Quote:enabled.snt is one of the grunt's sound files and i tried the fade at 0.0f but still no sound in-game,

just out of curiosity, is this a common problem? or is it just my game specifically?

Most likely just a coding or some small detail we're overlooking. Just for testing sake, try this instead.


PlaySoundAtEntity("", "enabled.snt", "Player", 0.0f, false);

It'll play directly on the player, letting them hear it regardless. If it doesn't play, it's .snt file. Which alternatively, you can try a different .snt and test that.

Ahh, that worked perfectly! Thank you very much.

However are there any disadvantages to playing the sound directly from "Player"? Because i was planning to have quite a few triggered sounds and i might end up having to use this method for all of them.
03-02-2011, 09:37 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#8
RE: Adding a Sound Triggered by an Area

Well, the only thing that I see wrong with it, is if you wanted the sound the play at the end of a hall and want the player to know specifically it's coming from down the hall.

When it's played on the Player, it'll play the sound as if the sound if coming from the player, they'll hear it in all directions.
03-02-2011, 09:45 PM
Find
Nye Offline
Senior Member

Posts: 250
Threads: 8
Joined: Jan 2011
Reputation: 2
#9
RE: Adding a Sound Triggered by an Area

(03-02-2011, 09:37 PM)Samuelblitz Wrote:
(03-02-2011, 08:17 AM)Russ Money Wrote:
Quote:enabled.snt is one of the grunt's sound files and i tried the fade at 0.0f but still no sound in-game,

just out of curiosity, is this a common problem? or is it just my game specifically?

Most likely just a coding or some small detail we're overlooking. Just for testing sake, try this instead.


PlaySoundAtEntity("", "enabled.snt", "Player", 0.0f, false);

It'll play directly on the player, letting them hear it regardless. If it doesn't play, it's .snt file. Which alternatively, you can try a different .snt and test that.

Ahh, that worked perfectly! Thank you very much.

However are there any disadvantages to playing the sound directly from "Player"? Because i was planning to have quite a few triggered sounds and i might end up having to use this method for all of them.

The issue here, which I found out the hard way, you CANNOT play sounds from entities. As silly as it sounds, there are a few exceptions, like the player. And don't stick to the partial solution, since you might as well play a GuiSound if you want to play a sound from the player.

The solution is to create a script area and play the sound from that script area.

Sleepy

03-02-2011, 09:45 PM
Find
Samuelblitz Offline
Junior Member

Posts: 16
Threads: 4
Joined: Feb 2011
Reputation: 0
#10
RE: Adding a Sound Triggered by an Area

(03-02-2011, 09:45 PM)Nye Wrote:
(03-02-2011, 09:37 PM)Samuelblitz Wrote:
(03-02-2011, 08:17 AM)Russ Money Wrote:
Quote:enabled.snt is one of the grunt's sound files and i tried the fade at 0.0f but still no sound in-game,

just out of curiosity, is this a common problem? or is it just my game specifically?

Most likely just a coding or some small detail we're overlooking. Just for testing sake, try this instead.


PlaySoundAtEntity("", "enabled.snt", "Player", 0.0f, false);

It'll play directly on the player, letting them hear it regardless. If it doesn't play, it's .snt file. Which alternatively, you can try a different .snt and test that.

Ahh, that worked perfectly! Thank you very much.

However are there any disadvantages to playing the sound directly from "Player"? Because i was planning to have quite a few triggered sounds and i might end up having to use this method for all of them.

The issue here, which I found out the hard way, you CANNOT play sounds from entities. As silly as it sounds, there are a few exceptions, like the player. And don't stick to the partial solution, since you might as well play a GuiSound if you want to play a sound from the player.

The solution is to create a script area and play the sound from that script area.

Sleepy

Really? That sounds perfect, thanks for your help too Nye, i'll reply again if there are any more problems Smile

i actually have a few more questions about editing that i would be grateful for your help on, and i don't think i want to spam this board with more help threads:

- I'm trying to set it so when i interact with a locked door WITHOUT the key in my inventory, text will appear on screen telling me that i need to find the key. However i also want a quest to be added at the same time.

The problems i'm having are that no text pops up in-game, BUT it does show the little memento icon in the corner, however when i check that quest, the the text just says " - " like it's missing text...

this is my .hps:

"void TouchLockedDoor(string &in asEntity)

{
if(HasItem("Storage_Room_Key")) SetMessage("Hints", "HaveKeyLockedDoor1", 6.0f);
else AddQuest("Quests", "QuestLockedDoor1");
SetMessage("Hints", "LockedDoor1", 6.0f);


}"


and this is my extra_english.lang:

"<LANGUAGE>

<CATEGORY Name="Hints">
<Entry Name="LockedDoor1"> The door is locked sturdily.</Entry>
<Entry Name="LockedCrowBarDoor1"> The door is locked with an old, weak lock.</Entry>
<Entry Name="HaveKeyLockedDoor1"> You need to use the key on the door to unlock it.</Entry>
<Entry Name="HaveCrowBarCrowBarDoor1"> You need to use the crowbar on the door to break the lock.<Entry>

</CATEGORY>
<CATEGORY Name="Quests">
<Entry Name="QuestLockedDoor1"> I need to find the key for the Storage Door.</Entry>
<Entry Name="QuestCrowBarDoor1"> I need to find a way to break the lock.</Entry>

</LANGUAGE>"

in-case your wondering, the "HaveKeyLockedDoor1" should just display a message telling you that you need to drag the key to the door.

thanks for your help! Smile
03-03-2011, 12:09 AM
Find




Users browsing this thread: 3 Guest(s)