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
Sound Help
Placeable Offline
Junior Member

Posts: 21
Threads: 2
Joined: Sep 2010
Reputation: 0
#2
RE: Sound Help

Hey Stangi

I'll try and post a thorough explanation for you Smile

First if all your Area (Script) must have a name and instead of a sound object placed out you would place out a new Area (Script) and give it a name as well. This is where we want to play our sound from.

I'll call them myTrigger and SoundArea.

Then in your script (.hps) file for your area you would add the following line of code to check for 'collision/collide' with the area.

AddEntityCollideCallback("Player", "myTrigger", "PlaySound", true, 0);

Put it where you see fit, I'd recommend the OnStart() function for the area, depending on what you really want to do.

As you can see in the function's parameters we have "Player", that is the entity/object that will collide with the trigger; in this case simply the player.

Then we have "myTrigger", that is our trigger area which the object will collide with. Once this happens we will call on a function simply named PlaySound.

You have to define this function and it is here you'll play your sound. I'd do it like this:

void PlaySound(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("someSound", "general_rain_m.snt", "SoundArea", 0, true);    
}

This would give you a rain sound playing at the SoundArea.

Alternatively if you want to have a placed out sound, like you mentioned in your post, we could 'disable' this sound by checking off the 'Active' box in its properties. And when the player is entering the myTrigger area we could simply enable the sound with the following code:

SetEntityActive("specialSound", true);

In the PlaySound() function instead.

The sound you placed out would be called specialSound.

Hope this helps!
10-01-2010, 05:47 PM
Find


Messages In This Thread
Sound Help - by Stangi - 10-01-2010, 03:13 PM
RE: Sound Help - by Placeable - 10-01-2010, 05:47 PM
RE: Sound Help - by Stangi - 10-01-2010, 09:03 PM
RE: Sound Help - by Placeable - 10-01-2010, 09:59 PM
RE: Sound Help - by Stangi - 10-01-2010, 10:52 PM
RE: Sound Help - by Placeable - 10-01-2010, 11:25 PM
RE: Sound Help - by Stangi - 10-02-2010, 08:44 PM



Users browsing this thread: 1 Guest(s)