# Why when adding audio foot steps to the character using animation events only one foot play the sound?

The animation in the Animator is HumanoidWalk In the inspector of the animation in the Animation tab at the bottom I clicked on the Events clicked to add event names the function as Step and moved the time slider to 0.67 moved the slider in the preview window of the character so the right leg foot will be close to the ground and clicked on apply:

Then I did the same but changed the time a bit more almost to 0.7 and called the function Step again and at the preview window now it';s the other leg foot close to the ground and clicked apply:

I added to the character in the hierarchy a Audio Source component and a script name Foot Steps:

And the script it self:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FootSteps : MonoBehaviour
{
[SerializeField]
private AudioClip[] clips;

private AudioSource audioSource;
private GameObject[] Foots;

private void Awake()
{
audioSource = GetComponent<AudioSource>();
Foots = GameObject.FindGameObjectsWithTag("Foot");
}

private void Step()
{
AudioClip clip = GetRandomClip();
audioSource.PlayOneShot(clip);
}

private AudioClip GetRandomClip()
{
return clips[UnityEngine.Random.Range(0, clips.Length)];
}
}


In the Hierarchy in the script in Clips I added same 8 audio clips just for the testing I could add only 1 it doesn't matter:

When running the game I marked with blue circle only this foot play the step/s sounds. And if I change the time to be the same 0.67 it will play two sound the same so it will sound like one or if the time is 0.67 and 0.7 it will hear two steps but only on the left leg foot.

The second leg foot never play the sound no matter how many times I changed the preview animation legs.

I tried to follow the instructions of this tutorial but no success:

Should be simple but only one foot is working. I can't figure out what am I missing.

I have had trouble calling events on the animator. This doesn't answer your specific question but provides another solution. The way I do footstep sounds is to raycast from the foot bone and play the footstep sound effect that corresponds to the surface which the raycast collides with. You can set the surface type several ways. I use layer mask since it is easily integrated with Physics.Raycast(). Physics.Raycast reference

private void PlayFootStepSound(){
RaycastHit hit;

if(Physics.Raycast(footBone.transfrom.position,
-footBone.tranform.up, out hit, stepDistance, surfaceLayer){

// make the magic happen....
}
}


Hope this helps.

"You're adding your events at the wrong timestamps. Take a look at the little white line in the "Events" timeline. In your first screenshot, the line is right past 0:33 and in your second screenshot, the line is slightly right of 0:83. That's where your events should be (not 0:67 and 0:70)."

It was my wrong thought that I need to set the timestamp on my own. Instead all I needed to do is to set in the preview window each time the step of the character for each foot and when clicking on the add event button it's setting the timestamp automatic. And I was setting it on my own. This part was not explained in the video tutorial I followed: