public void OnTriggerEnter2D(Collider2D other) { if (canAttack && other.transform.tag == "monster") { monsterAI script = (monsterAI)other.transform.GetComponent(typeof(monsterAI)); script.TakeDamage(damage); canAttack = false; } }
public void OnTriggerEnter2D(Collider2D other) { if (other.transform.tag == "monster") { monsterAI script = (monsterAI)other.transform.GetComponent(typeof(monsterAI)); script.TakeDamage(damage); myGameObject.SetActive(false); } else if (other.transform.tag == "obstacle") { myGameObject.SetActive(false); } }