Hello to everyone I take script from this question: Footstep sounds when walking - Questions & Answers - Unity Discussions and modify it a little but in the part of Script audio.clip = concreteSound[Random.Range(0, concreteSound.Lenght)]; the “Length” make an Error does not contain a definition. Can some one please help me to fix it.
Here is the full Script:
public class footStepSoundControll : MonoBehaviour {
public CharacterController controller;
public AudioClip concreteSound;
private bool step = true;
float audioStepLengthWalk = 0.45f;
// Use this for initialization
void Start () {
controller = GetComponent<CharacterController>();
}
void OnControllerColliderHit (ControllerColliderHit hit)
{
//Debug.Log("Controller hit the ground");
if (controller.isGrounded && controller.velocity.magnitude < 7 && controller.velocity.magnitude > 5 && hit.gameObject.tag == "Untagged" && step == true )
{
WalkOnConcrete();
}
}
IEnumerator WaitForFootSteps(float stepsLength)
{
step = false;
yield return new WaitForSeconds(stepsLength);
step = true;
}
public void WalkOnConcrete ()
{
audio.clip = concreteSound[Random.Range(0, concreteSound.Lenght)];
audio.volume = 0.1f;
audio.Play();
StartCoroutine(WaitForFootSteps(audioStepLengthWalk));
}
}