So at the moment I'm suck trying to make a enemy stop after being hit. The problem is that I can't use the collision.name because it doesn't exist in the context but I also can't put Collider2D as a parameter on the end of the function because I need the int damage there. So how would I be able to do this?
public void TakeDamage(int damage)
{
anim.SetTrigger("hurt");
if(collision.name == Hawk)
{
GetComponent().enabled = true;
}
health -= damage;
if (health <= 0)
{
Destroy(gameObject);
}
}
↧