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 Sound-Area doesn't work [Solved]
ShipinShen Offline
Junior Member

Posts: 23
Threads: 7
Joined: Apr 2014
Reputation: 0
#1
Sound-Area doesn't work [Solved]

Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?

ShipinShen - YouTube
(This post was last modified: 04-22-2014, 04:19 PM by ShipinShen.)
04-22-2014, 02:41 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Sound-Area doesn't work

Is your .snt file set to loop? Why is this sound only playing when you collide with the area? You could just have it play at all times with a low radius.

04-22-2014, 02:51 PM
Find
ShipinShen Offline
Junior Member

Posts: 23
Threads: 7
Joined: Apr 2014
Reputation: 0
#3
RE: Sound-Area doesn't work

(04-22-2014, 02:51 PM)Mudbill Wrote: Is your .snt file set to loop? Why is this sound only playing when you collide with the area? You could just have it play at all times with a low radius.

Thats right.
OnStart()
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

Is this correct ?
Thats the .snt file
Quote:<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="ClockChime" />
</Main>
</SOUNDS>
<PROPERTIES Volume="0.7" MinDistance="2" MaxDistance="16" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="True" Blockable="False" BlockVolumeMul="0.8" Priority="0" />
</SOUNDENTITY>

ShipinShen - YouTube
04-22-2014, 02:54 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Sound-Area doesn't work

What kind of sound is this, and how do you want it to play? Do you only want a single ding-dong to occur when the player comes close to the clock? You could try making the Priority="1" instead. Where are the audio files located?

04-22-2014, 02:57 PM
Find
ShipinShen Offline
Junior Member

Posts: 23
Threads: 7
Joined: Apr 2014
Reputation: 0
#5
RE: Sound-Area doesn't work

(04-22-2014, 02:57 PM)Mudbill Wrote: What kind of sound is this, and how do you want it to play? Do you only want a single ding-dong to occur when the player comes close to the clock? You could try making the Priority="1" instead. Where are the audio files located?

Thats this sound https://www.youtube.com/watch?v=tOIA9Ii2Ihk
The clock is in a room, and i want that the sound come from the clock, i just looped the sound a bit longer so the chimes wont appear 2 times if someone stays longer in this room.

The audiofiles are located in C:\Program Files (x86)\Steam\SteamApps\common\Amnesia The Dark Descent\custom_stories\Haunted Mind\sounds the sounds should work, because the phonogram works

ShipinShen - YouTube
04-22-2014, 03:00 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#6
RE: Sound-Area doesn't work

If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.

04-22-2014, 03:33 PM
Find
ShipinShen Offline
Junior Member

Posts: 23
Threads: 7
Joined: Apr 2014
Reputation: 0
#7
RE: Sound-Area doesn't work

(04-22-2014, 03:33 PM)Amn Wrote: If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.

The sound is 5minutes long, the fade time shouldnt be a problem..
The entity is in the room so i can walk to the clock instantly. Maybe its the intro who stops the sound ?

Quote:void OnStart()
{
TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntro");

SetEntityCallbackFunc("Lantern", "OpenDoor");
SetLocalVarInt("Door", 0);




AddUseItemCallback("", "KeyTable", "DeskDoor", "UseKeyOnDoor", true);
PlayMusic("RainyMood.ogg", false, 1, 3, 1, true);

PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 0, false);
}
Quote:void TimerIntro(string &in asTimer)
{
if(GetLocalVarInt("Intro") < 3) {

if(asTimer == "fadein") {
TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
FadeIn(1);
AddTimer("fadeout", 4, "TimerIntro");
}
if(asTimer == "fadeout") {
FadeOut(1);
AddTimer("fadein", 1, "TimerIntro");
AddLocalVarInt("Intro", 1);
}
}
else
{
TeleportPlayer("Spawn");
FadeIn(2);
SetPlayerActive(true);
SetSanityDrainDisabled(false);
ShowPlayerCrossHairIcons(true);
}
}
The Intro works fine. After the intro, the player stands in near of the entity "grandfather"

(04-22-2014, 02:41 PM)ShipinShen Wrote: Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?

I know where the mistake is.. the sound file works fine, because when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "Player", 1, false); I can hear the noise, but i dont understand, why the sound doesnt work when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false); the entity has the exact same name in the level editor and the same .snt settings than the phonogram, which works fine

(04-22-2014, 03:56 PM)ShipinShen Wrote:
(04-22-2014, 03:33 PM)Amn Wrote: If your sound is too short, maybe the fade time 1 is causing trouble. Try with 0.
Also check grandfather it should be an entity or area close to the player. And enabled.
And last, make sure your sound is called ClockChime.ogg and it's mono.

The sound is 5minutes long, the fade time shouldnt be a problem..
The entity is in the room so i can walk to the clock instantly. Maybe its the intro who stops the sound ?

Quote:void OnStart()
{
TeleportPlayer("Intro_0");
FadeOut(0);
SetPlayerActive(false);
SetSanityDrainDisabled(true);
ShowPlayerCrossHairIcons(false);

AddTimer("fadein", 3, "TimerIntro");

SetEntityCallbackFunc("Lantern", "OpenDoor");
SetLocalVarInt("Door", 0);




AddUseItemCallback("", "KeyTable", "DeskDoor", "UseKeyOnDoor", true);
PlayMusic("RainyMood.ogg", false, 1, 3, 1, true);

PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 0, false);
}
Quote:void TimerIntro(string &in asTimer)
{
if(GetLocalVarInt("Intro") < 3) {

if(asTimer == "fadein") {
TeleportPlayer("Intro_" + GetLocalVarInt("Intro"));
FadeIn(1);
AddTimer("fadeout", 4, "TimerIntro");
}
if(asTimer == "fadeout") {
FadeOut(1);
AddTimer("fadein", 1, "TimerIntro");
AddLocalVarInt("Intro", 1);
}
}
else
{
TeleportPlayer("Spawn");
FadeIn(2);
SetPlayerActive(true);
SetSanityDrainDisabled(false);
ShowPlayerCrossHairIcons(true);
}
}
The Intro works fine. After the intro, the player stands in near of the entity "grandfather"

(04-22-2014, 02:41 PM)ShipinShen Wrote: Hey guys, I added an area and an entity for example the grandfather clock.
I named the Area "ClockChime", the PlayerInteractCallback "Clock" and the Clock "grandfather". The Sound name is "ClockChime.snt".

Quote:void OnStart()
{
AddEntityCollideCallback("Player", "ClockChime", "Clock", true, 1);
}

void Clock(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false);
}

When i'm colliding with this area ingame, nothing happens.. where is my mistake ?

I know where the mistake is.. the sound file works fine, because when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "Player", 1, false); I can hear the noise, but i dont understand, why the sound doesnt work when i'm writing PlaySoundAtEntity("Clock", "ClockChime.snt", "grandfather", 1, false); the entity has the exact same name in the level editor and the same .snt settings than the phonogram, which works fine

I solved it, by adding an area which names "grandfather" !

ShipinShen - YouTube
(This post was last modified: 04-22-2014, 04:19 PM by ShipinShen.)
04-22-2014, 03:56 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#8
RE: Sound-Area doesn't work [Solved]

Oh boy, that's a lot of quoting.

But yeah, that actually makes sense, because the grandfather clock is likely a static entity type, so interacting with it won't work. I prefer to use areas for these things anyway, gives me more control. Glad you got it working!

04-22-2014, 05:59 PM
Find




Users browsing this thread: 2 Guest(s)