Frictional Games Forum (read-only)
Play sound when walking? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Play sound when walking? (/thread-8591.html)



Play sound when walking? - ZortaEnzane - 06-14-2011

Is it possible to make a specific sound to play whenever the player takes a step? (other than the footstep sound of course, and I don't this sound to replace the footsteps either if that's at all possible)

To be more precise, say I wanted it to sound like there are chains dragging along with you... how would I do that?


RE: Play sound when walking? - Nye - 06-14-2011

(06-14-2011, 12:24 AM)ZortaEnzane Wrote: Is it possible to make a specific sound to play whenever the player takes a step? (other than the footstep sound of course, and I don't this sound to replace the footsteps either if that's at all possible)

To be more precise, say I wanted it to sound like there are chains dragging along with you... how would I do that?

Besides doing some sort of full-conversion; I can think of some vague idea. I suppose you could create several columned areas across the map, eg. 30 script areas in columned strips. Each time the player collides with a strip, you play the guisound of a chain rattle? You would need lots of different chain rattle sounds to avoid it getting annoying, and you would need to create a timer on each chain rattle, which prevents the rattles from stacking, ie. using local variables to allow only one rattle every 5 seconds max.

At least, that's how I would do it.

|
|__ If you need any help with this, PM me or add my MSN (joenye@hotmail.co.uk)

EDIT: Your voice acting portfolio is really good! I would love for you to record a few lines for my next custom story, if that is okay (not needed for a few weeks yet) Big Grin


RE: Play sound when walking? - xiphirx - 06-14-2011

This is quite easy to do with scripting. First, you need the sound effects, I suppose you already have them.

In OnEnter
Code:
AddTimer("tmrChainRattle", 0.1f, "ChainRattle");

Then this function
Code:
void ChainRattle(string &in asTimer)
{
    if (GetPlayerSpeed() > 0.0f)
    {
        PlaySoundAtEntity(SOUNDNAME, SOUNDFILE, 'Player', 0.0f, false);
        AddTimer('tmrChainRattle', GetPlayerSpeed(), 'ChainRattle');
    }
    else
    {
        AddTimer('tmrChainRattle', 0.1f, 'ChainRattle');
    }
}

What this does is continually check whether the player is moving, if the player is moving, then play the chain rattle sound, and set a timer off that will continue to play the sound in-sync with the stepping sounds.

NOTE: It may be out of sync right now, you will have to mess with the timings. Also, for the different states of walking or running, you can do a if block to target specific player speeds. Use debug messages to see how fast the player moves Smile


RE: Play sound when walking? - Nye - 06-14-2011

^ I didn't think of using getplayerspeed, that's a better way of doing this I think Smile