Example #1
0
 // Use this for initialization
 void Start()
 {
     _aiCarControl  = GetComponent <AICarControl>();
     _carController = GetComponent <CarController>();
     _odometer      = GetComponent <CarOdometer>();
     _crashed       = false;
 }
 // Use this for initialization
 void Awake()
 {
     currentHealth = startingHealth;
     enemyMovement = GetComponent <AICarControl> ();
     thisRb        = GetComponent <Rigidbody> ();
     childRBs      = GetComponentsInChildren <Rigidbody> ();
     foreach (Rigidbody rb in childRBs)
     {
         if (rb != thisRb)
         {
             rb.isKinematic      = true;
             rb.detectCollisions = false;
         }
     }
 }
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         MoveCarForce playerMovement = other.GetComponent <MoveCarForce> ();
         if (playerMovement != null)
         {
             playerMovement.maxSpeed += 10f;
             Debug.Log("Player's max speed is: " + playerMovement.maxSpeed);
         }
         Destroy(gameObject);
     }
     else if (other.CompareTag("Enemy"))
     {
         AICarControl enemyMovement = other.GetComponent <AICarControl> ();
         if (enemyMovement != null)
         {
             enemyMovement.maxSpeed += 10f;
             Debug.Log("Enemy's max speed is: " + enemyMovement.maxSpeed);
         }
         Destroy(gameObject);
     }
 }