- Home /
AudioSource not repeating at correct times
I'm trying to create footsteps for my Character Controller. I'm currently doing this by seeing if the controller is grounded, and if they are moving to play to footstep sound. I also check to see if the sound is already playing, so it won't continuously play.
Here's the code:
if (controller.isGrounded && controller.velocity.magnitude > 2f && !footstepSound.isPlaying)
{
footstepSound.volume = Random.Range(.8f, 1f);
footstepSound.pitch = Random.Range(.8f, 1.1f);
footstepSound.Play();
}
But for some reason, the AudioSource sometimes takes longer than it should to play again. The audio clip is .515 seconds long, but it sometimes takes a second or longer to play the audio again. This results in uneven footsteps sounds, even when I comment out the random pitch & volume. What am I doing wrong?
Your answer
Follow this Question
Related Questions
Audio loops too early 2 Answers
No overlapping sounds 0 Answers
Question about audio (AudioSource). My ingame sound doesn't sound like the original audio file? 3 Answers
Can't seem to play my AudioClip? 2 Answers