// A collider has exited the front trigger public void TriggerExited(Collider collider, TriggerType triggerType) { // Something exited right in front of the vehicle? if (triggerType == TriggerType.Stop) { brakeHard = true; } // Was it a vehicle? if (collider.gameObject.transform.parent.gameObject.CompareTag(this.gameObject.tag)) { if (vehicleInFront != null) { if (vehicleInFront.Equals(collider.gameObject.GetComponent <VehicleController>())) { vehicleInFront = null; } } } // Was it a trigger to stop? if (collider.CompareTag("StopTrigger")) { stopOnLight = false; hitTrafficLightController = null; } }