So I have a Custom Weapon with Custom Animation attached to my player. When the player Left-Clicks it plays the animation and sound. However if the player repeatedly left clicks the sound restarts over and over again interrupting itself. How can I tell the engine in JavaScript, to wait a certain amount of time before playing the sound again? I’m using the sound attached to the weapon as a AudioSource Component. Here is the code I’m using to play the animation and sound.
function Update () {
if(Input.GetButtonDown("Fire1"))
{
animation.Play("Punch");
audio.Play();
}
}