Here's the aforementioned script:
public float attackDuration = 0.3F;
public bool attacking;
[HideInInspector]
void Start()
{
}
void Update()
{
if (Input.GetButtonDown("Attack"))
{
attacking = true;
}
EnableDamage();
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag =="Enemy")
{
if (col.tag == "Enemy")
{
col.SendMessage("LevaDano", 1, SendMessageOptions.DontRequireReceiver);
}
}
}
void EnableDamage()
{
if (attacking == true) return;
attacking = true;
StartCoroutine("DisableDamage");
}
IEnumerator DisableDamage()
{
yield return new WaitForSeconds(attackDuration);
attacking = false;
}
The main problem is that i can't get `attacking` back to `false` no matter what. How to proceed? Also, feel free to warn me about any other bugs.
↧