How to stop footstep sound when jumping, but continue when hitting the ground?

I’m new to Unity (and scripting in general), and I have started making a first person adventure game.

I have been able to get sound effects for walking and jumping to work, but the problem is that the walking sound plays even in the air, when jumping and pressing any of the movement keys in the air.

I’ve tried stopping the footstep sound with audio.Stop when the jump button is pressed, but this leaves another problem:
The footstep sound doesn’t continue when the player hits the ground, if one of the movements keys was pressed the whole time (a lot of cases when jumping forward and continuing movement after landing).

Is there a(n easy) way to make the footstep sound continue after landing?

Here’s my sound script so far (without the audio.Stop, since it didn’t work like a wanted):

var jumpSound : AudioClip;

var stepSound : AudioClip;

function Update () {

if ( Input.GetButtonDown ( "Jump" )){   

 audio.PlayOneShot(jumpSound); }


if ( Input.GetButtonDown ( "Horizontal" ) || Input.GetButtonDown ( "Vertical" )){  

 	 audio.clip = stepSound;

 	 audio.loop = true; 




if ( Input.GetButtonUp ( "Horizontal" ) || Input.GetButtonUp ( "Vertical" )){




Instead of doing this with code, you should use animation events and sync the sounds there. That way when you jump and you play the jump animation the animation events for walking won’t get fired. You can read more about animation events here:,