// Update is called once per frame void Update() { TextMesh.transform.rotation = Camera.main.transform.rotation; TankHealth TH = GetComponent <TankHealth>(); TextMesh.color = new Color(0.95f, 0.95f - TH.GetVulnerability() * 0.05f, 0.95f - TH.GetVulnerability() * 0.05f); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Tank") { Collider[] TankColliders = Physics.OverlapSphere(transform.position, ExplosionRadius, TankMask); foreach (Collider C in TankColliders) { Rigidbody TargetBody = C.GetComponent <Rigidbody>(); if (!TargetBody) { continue; } TankHealth Tank = TargetBody.GetComponent <TankHealth>(); if (!Tank) { continue; } //Calculate FinalForce To Apply float FinalForce = BaseForce + Tank.GetVulnerability() * AddedForce; //Apply ExplosionForce TargetBody.AddExplosionForce(FinalForce, transform.position, ExplosionRadius); //Add Vulnerability To Tank Tank.AddVulnerability(); } // Unparent the particles from the shell. ExplosionParticle.transform.rotation = Quaternion.identity; ExplosionParticle.transform.parent = null; // Play the particle system. ExplosionParticle.Play(); ParticleSystem.MainModule MainModule = ExplosionParticle.main; Destroy(ExplosionParticle.gameObject, MainModule.duration); //Destroy Bullet Destroy(gameObject); } }