How to play and stop the sound of footsteps?

I’ve created my own footstep sound, but now I’m trying to implement the sound into Unreal Engine. I want it where everything you press the W,A,S,D keys the sound of the footsteps will be played, but when you release the keys I want the sound to stop. I’ve already made a sound cue already, but I just don’t know how to play and stop the sound cue. I was wondering if anyone could help me with this? This will help me with other sounds that I’m trying to implement as well. :slight_smile:

If you have a 3rd Person Mesh, you could line up the sound with the animation via the animation blueprint. :X

Unfortunately the project that I’m working on isn’t third person. Do you have any other solutions?

Seeing that you don’t actually have an animation to attach the sounds to, on Pressed, activate a custom event that does Play From Start on a Timeline. Double click to go into its editor and set the Timeline to looping, and set the Length to the amount of time you want between footsteps. Create an event track and add an event on time 0. You’ll now have a custom event exec pin coming out of the Timeline that will fire off every time it loops. That will fire into a node that plays your sound.

For varying speeds, you would have it fire into a different Timeline that’s shorter.

On key Released, fire into a custom event that does Stop on the Timeline.

I’m really struggling with this, and I was wondering if you could provide visual aid to help me out? I hope this isn’t too much trouble, but just can’t stop the sound of the footsteps when you release the key. Yes, I would like to speed up the footsteps when the character sprints, but I’m unsure on how to do this as well. :frowning:

Create your Timeline. Double click to go into it. For this example I set the Length to .6 and set the Loop checkbox to checked. This Timeline will now loop every .6 seconds. I created an Event Track (with that “!” looking button), right clicked to create a key, and set it to Time 0 and value 0. It will now fire off a custom event at time 0 every time it loops, so every .6 seconds.

For the BP setup, you simply use that custom event to trigger your sound. You can use Play Sound At Attached and attach it to a player component, like the mesh or something, or use Play Sound At Location and use the player’s location. Whatever you want. I set up “walk” system and a “sprint” system. In the sprint one I set the Length to .3 and looping with an event track key at time 0, so it will fire off a footstep sound every .3 seconds.

I also created custom events, for playing the walk system, stopping the walk system, playing the sprint system, and stopping the sprint system.

Finally, the controls. I used just W as an example, with Left Shift for the sprint button. Use whatever you need to use. What’s important here is the logic. Pressing W triggers the playing of the walk footsteps, as well as allowing Left Shift to do anything. You don’t want sprint to do anything unless you are already moving, at least if what you’re using is a sprint toggle button like this.

Releasing W stops any footstep sounds from happening, as well as blocking Left Shift from doing anything.

Pressing Left Shift only does something when allowed, and it stops the walk footsteps and plays the spring footsteps. It simply does the opposite when released, as long as it is allowed to.

Let me know if you need more info!

1 Like

Checking in! Everything work okay?

Everything is fine, but I used a different method before you posted your answer. I realized that I had the FP_Animations within my content browser, so I decided to add the FP mesh, but make it invisible when rendering. I basically added my sound files within those animations. Thanks for your help anyway, and the images that you’ve provided will help me still. I still need to implement the heavy breathing sound effect, so I can use the timeline method for that. :slight_smile: I’m busy with other college projects, but I’ll update you when I’ve implemented the sound effect.

Adding them as events in the animation is definitely the preferred method! Glad you’re able to use that much easier route

Hey I followed this method of yours and works perfectly!

One problem I have though is that if I trigger the sound via the other movement buttons (A,S,D) then it layers two sounds on top of each other. So when I am moving diagonally (Pressing let’s say A and W together) they both start playing the footsteps sound?.

Is there an easy and simple way of only one of them playing? Maybe W overriding A when both are pressed.

Sorry I’m quite new to blueprints, so my understanding is somewhat limited. Here is a screen shot of my current progress: