I wrote up this javascript and have no compiler errors, but when i walk i don’t hear any footstep sounds. What’s wrong? I tagged the objects correctly too.
var AudioTimer : float = 0;
var ConcreteSound: AudioClip;
var MetalSound: AudioClip;
function Update () {
if(AudioTimer > 0){
AudioTimer -= Time.deltaTime;
}
if(AudioTimer < 0){
AudioTimer = 0;
}
}
function OnControllerColliderHitt (col: ControllerColliderHit){
if(col.gameObject.CompareTag("concrete") && Input.GetAxis("Vertical") && AudioTimer == 0 ||
Input.GetAxis("Horizontal") && AudioTimer == 0 ){
audio.clip = ConcreteSound;
audio.PlayOneShot(ConcreteSound);
AudioTimer = 0.5;
}
if(col.gameObject.CompareTag("metal") && Input.GetAxis("Vertical") && AudioTimer == 0 ||
Input.GetAxis("Horizontal") && AudioTimer == 0 ){
audio.clip = MetalSound;
audio.PlayOneShot(MetalSound);
AudioTimer = 0.5;
}
}
i deleted the capsule graphics from it
– inglipXNo capsule no character controller. Keep the capsule but do not use it for the purpose of footstep sound. I can help you more than that...you are heading the wrong way trying to do your sound system into the collision function.
– fafase