Example #1
0
 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();
         }
     }
 }
Example #2
0
 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);
         }
     }
 }