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
Play sound when walking?
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
#3
RE: Play sound when walking?

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

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

Then this function
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

06-14-2011, 01:28 AM
Find


Messages In This Thread
Play sound when walking? - by ZortaEnzane - 06-14-2011, 12:24 AM
RE: Play sound when walking? - by Nye - 06-14-2011, 12:53 AM
RE: Play sound when walking? - by xiphirx - 06-14-2011, 01:28 AM
RE: Play sound when walking? - by Nye - 06-14-2011, 01:32 AM



Users browsing this thread: 1 Guest(s)