private void Update() { //Debug.Log(Vector3.Distance(transform.position, _localTarget)); if (Vector3.Distance(transform.position, _localTarget) < trackerSensitivity) { //Debug.Log("got here"); if (progressPercentage >= 1f) { progressPercentage = 0f; } else { progressPercentage += precision; //Debug.Log(progressPercentage); } _localTarget = path.GetPoint(progressPercentage); } Vector3 localTargetTransform = transform.InverseTransformPoint(path.GetPoint(progressPercentage)); _targetAngle = (localTargetTransform.x / localTargetTransform.magnitude); float speedFactor = _carController.GetCurrentSpeed() / _carController.GetMaximumSpeed(); float corner = Mathf.Clamp(Mathf.Abs(_targetAngle), 0, 90); float cornerFactor = corner / 90.0f; float brake = 0; if (corner > 10 && speedFactor > 0.05f) { brake = Mathf.Lerp(0, 1 + speedFactor * brakeFactor, cornerFactor); } float accel = 1f; if (corner > 20 && speedFactor > 1f) { accel = Mathf.Lerp(0, 1 * accelerationCareFactor, 1 - cornerFactor); } if (!manualOverride) { // _carController.MoveVehicle(accel, brake, _targetAngle); if (_carController.GetCurrentSpeed() >= aimedSpeed) { brake += 50f; _carController.MoveVehicle(accel, brake, _targetAngle); } else { _carController.MoveVehicle(accel, brake, _targetAngle); } } }