Example #1
0
    private void OnTriggerExit(Collider other)
    {
        GearRotation otherGear = other.GetComponent <GearRotation>();

        if (drivingID > 0 && drivingMotor && other.GetInstanceID() == drivingMotor.GetInstanceID())
        {
            drivingMotor = null;
            rigidBody.angularVelocity = AngularVelocity;
            drivingID = 1000;
        }
    }
Example #2
0
 private void OnTriggerStay(Collider other)
 {
     if (drivingID > 0 && other.tag.Equals("Gear"))
     {
         GearRotation otherGear = other.GetComponent <GearRotation>();
         if (otherGear.drivingID < drivingID)
         {
             drivingID    = otherGear.drivingID + 1;
             drivingMotor = otherGear;
             rigidBody.angularVelocity = AngularVelocity;
         }
     }
 }
Example #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (drivingID > 0 && other.tag.Equals("Gear"))
     {
         GearRotation otherGear = other.GetComponent <GearRotation>();
         if (otherGear.drivingID < drivingID)
         {
             drivingID    = otherGear.drivingID + 1;
             drivingMotor = otherGear;
             rigidBody.angularVelocity = AngularVelocity;
             if (load)
             {
                 load = false;
                 StartCoroutine(GearStillMoving());
             }
         }
     }
 }