DamageTaker dt; //A reference to the boss' health /// <summary> /// Overrides the base class to implement a DamageTaker reference and reset the attack duration on start up /// </summary> /// <param name="enemy"></param> public override void OnBegin(EnemyController enemy) { base.OnBegin(enemy); dt = enemy.GetComponent <DamageTaker>(); attackDuration = 5; }
void OnTriggerEnter(Collider collider) { //The projectile collided with an object DamageTaker dt = collider.GetComponent <DamageTaker>(); if (dt != null) //Do damage to the object { dt.TakeDamage(damageAmount); // Apply damage to the thing we hit Destroy(gameObject); // Destroy the bullet return; } }