private void OnTriggerEnter(Collider other) { Collider[] colliders = Physics.OverlapSphere(transform.position, shellExplosionRidus, tankMask); for (int i = 0; i < colliders.Length; i++) { Rigidbody collideTarget = colliders[i].GetComponent <Rigidbody>(); if (!collideTarget) { continue; } for (int j = 0; j < colliders.Length; j++) { TankHealth tankHealth = colliders[j].GetComponent <TankHealth>(); if (!tankHealth) { continue; } float damage = DamageCounter(colliders[j].GetComponent <Rigidbody>().position); tankHealth.HealthDown(damage); } ShellExplode(); } //throw new NotImplementedException(); }
private void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("Tank")) { /*if (Vector3.Magnitude(collision.rigidbody.velocity) >= m_MinCollideDamageVelocityTrigger || * Vector3.Magnitude(m_Rigidbody.velocity) >= m_MinCollideDamageVelocityTrigger) * {*/ float collideVelocity = Vector3.Magnitude(m_Rigidbody.velocity - collision.rigidbody.velocity); float collideDamageRatio = RatioCounter(collision); tankHealth.HealthDown(collideVelocity * collideDamageRatio * m_BasicCollideDamage); //} } }