public void OnTriggerEnter2D(Collider2D other) { if (canAttack && other.transform.tag == "monster") { monsterAI script = (monsterAI)other.transform.GetComponent(typeof(monsterAI)); script.TakeDamage(damage); canAttack = false; } }
protected override void Awake() { base.Awake(); unitLevel = 10; monster = GetComponent <monsterAI>(); maxHealth = (baseHealth + 10 * unitLevel) * (1 + increasedHealth); currentHealth = maxHealth; increasedAttackSpeed = 0; }
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); } }
private void Awake() { m_Character = GetComponent <PlatformerCharacter2D>(); monster = GetComponent <monsterAI> (); }