Hello Guys,
I am having a lot of trouble getting a sound to play while the FPS controller is walking using 4.6.1f. Yes, I know I should really be using Unity5 but I don’t want to mix the packages.
Anyway, the sound I am getting is close to electrical static than a foot step sound. I can sort of understand why it might be happening with the sound being generated within an update, but, I cannot figure out how to stop it occurring.
As always a big thankyou goes out to those who can help with this problem.
Regards,
CK.
The code I have used is as follows:
#pragma strict
var controller: CharacterController;
function Start () {
controller = GetComponent(CharacterController);
}
//playerwalking function
function Update () {
//print("isGrounded:"+controller.isGrounded+"Velocity:"+controller.velocity.magnitude);
if (controller.isGrounded && (controller.velocity.magnitude > 1 && controller.velocity.magnitude < 11) ) {
print("walkies........");
audio.Play();
}
else{
print("notwalkies...");
audio.Stop();
}
}//end function