void OnTriggerEnter(Collider other) { if (other.GetComponent <Rigidbody>() != null && other.gameObject != this && other.isTrigger) { Rigidbody targetRigidBody = other.GetComponent <Rigidbody>(); if (targetRigidBody.GetComponent <CarHealth>() != null) { CarHealth targetCarHealth = targetRigidBody.GetComponent <CarHealth>(); if (isShielded) { if (!targetCarHealth.isShielded) { targetCarHealth.TakeCollisionDamage(2 * collisionDamage); } else { targetCarHealth.RemoveShield(); } } else { if (!targetCarHealth.isShielded) { targetCarHealth.TakeCollisionDamage(collisionDamage); } else { targetCarHealth.RemoveShield(); } } } } }
private void OnTriggerEnter(Collider other) { if (other.GetComponent <CarMovement>() != null && other.isTrigger) { CarHealth targetCarHeath = other.GetComponent <CarHealth>(); if (targetCarHeath.IsShielded()) { targetCarHeath.RemoveShield(); Destroy(gameObject); } else { CarMovement targetCarMovement = other.GetComponent <CarMovement>(); targetCarMovement.SetCatOn(); } } }
private void OnTriggerEnter(Collider other) { if (other.GetComponent <Rigidbody>() != null && other.isTrigger) { CarHealth targetCarHeath = other.GetComponent <CarHealth>(); if (targetCarHeath.IsShielded()) { targetCarHeath.RemoveShield(); } else { Rigidbody rigidbody = other.GetComponent <Rigidbody>(); Rigidbody thisRigidBody = GetComponent <Rigidbody>(); rigidbody.AddForce(thisRigidBody.velocity * 10, ForceMode.Force); Destroy(gameObject); } } }