I was just wondering how to go about making it so my animation script will not repeat, but only play once, also adding some sort of a cool down to it. Thank you so much in advance, since I’m not that seasoned with scripting.
using UnityEngine;
using System.Collections;
public class attackAnim : MonoBehaviour
{
public string AttackButton;
public float attackSpeed;
private Animator anim;
private float attack;
void Start ()
{
anim = gameObject.GetComponent<Animator> ();
}
// Update is called once per frame
void Update ()
{
anim.SetFloat ("Attack", attack);
if(Input.GetKeyDown(AttackButton))
{
attack = attackSpeed;
}
if(attack > 0f)
{
attack -= Time.deltaTime;
}
}
}