Playing Audio Source with controls (Keys)
So I want to use a custom footstep, for my fox game, so like when I press "W" it will play, my script works, but it loops which I HATE because it ends up sounding like static, unlike the actual audio. Any suggestions?
My Script:
public AudioSource audioSource; public AudioClip audioClip;
void Start () { audioSource.clip = audioClip; }
void Forward() { if (Input.GetKey(KeyCode.W)) { GetComponent().Play("Default Take"); transform.Translate(0f, 0f, 0.5f); audioSource.Play(); } else if (!Input.GetKey(KeyCode.W)) { GetComponent().Stop("Default Take"); } }
Comment