Frictional Games Forum (read-only)

Full Version: Activate Sound entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is code considering sounds:
Code:
void CollidePianoArea(string &in asParent, string &in asChild, int alState)
{
  SetEntityActive("SoundPiano", true);
  AddTimer("", 45.0f, "EndPiano");
}

void EndPiano(string &in asTimer)
{
  SetEntityActive("SoundPiano", false);
}
And this is in void OnStart:
Code:
AddEntityCollideCallback("Player", "PianoArea", "CollidePianoArea", true, 1);

However it does not trigger when it should but instead it plays the sound right in the beginning. Also I have other similiar sound and it does the same.

Plus I have simple shelf that is set to inactive,(as all those sounds) but yet it is active right in the start of the map...

Edit: But few other entities are inactive as they should :S
You should only place sound entities with the level editor that loops and should be played all the time or until you want to stop them with StopSound.

You use PlaySoundAtEntity to play sounds when you like them to play. So remove SetEntityActive("SoundPiano", true); and do a PlaySoundAtEntity in its place.
Thank's Jens, but that does not explain why my shelf is active even though it is set inactive. There is not even any script considering that...
Could be a staticprop, which is a limited form of entity that is more like a static object than an entity.
(10-18-2010, 01:47 PM)jens Wrote: [ -> ]Could be a staticprop, which is a limited form of entity that is more like a static object than an entity.

Yeah, got it working with another entity.