void OnTriggerStay(Collider other) { if (other.attachedRigidbody && other.attachedRigidbody.gameObject) { switch (other.attachedRigidbody.gameObject.layer) { case Layers.player: case Layers.capital: case Layers.enemy: case Layers.enemyCollide: case Layers.enemyDestructibleBullet: case Layers.asteroid: m_damageDelay += Time.deltaTime; if (m_damageDelay >= m_tickTime) { HealthScript script = other.attachedRigidbody.gameObject.GetComponent <HealthScript>(); if (script) { script.DamageMobHullDirectly(m_damagePerTick); } else { Debug.LogError("Unable to find HealthScript on " + other.attachedRigidbody.name); } m_damageDelay = 0.0f; } break; } } }
// Destroy object using HealthScript private void DestroyByHealth(GameObject destroy) { if (destroy) { // Attempt to kill through the use of a HealthScript HealthScript health = destroy.GetComponent <HealthScript>(); if (health) { health.DamageMobHullDirectly(health.GetCurrHP() + 1); } // Fall back to network destruction else { DestroyByNetwork(destroy); } } }