i’ve seen some scripts of 2D Game play Tutorial Project file . and used it to my game character .and it seems very simple but i can’t imagine what’s wrong with it . after hit play the game and when my character walk,footstep sound is normal but when player run,the footstep sound can’t stay with foot step speed and slower . any body help me for this scripts . I used this script .
var audioStepLength = 0.3;
var walkSounds:AudioClip[];
function Start () {
var controller : CharacterController = GetComponent(CharacterController);
while (true)
{
if (controller.isGrounded && controller.velocity.magnitude > 0.3)
{
audio.clip = walkSounds[Random.Range(0, walkSounds.length)];
audio.Play();
yield WaitForSeconds(audioStepLength);
}
else
{
yield;
}
}
}
just like that . thanks
but my problem is good now .but audio loops very fastly . which line can fix this ? thank you
– alijanIncrease the minInterval value - it's the minimum time between footsteps. You can also tweak bias to adjust the progression of the effect: good values for bias are between 1 and maxVelocity.
– aldonaletto