Quellcode durchsuchen

Braking fix implemented

manuel.lehe vor 2 Jahren
Ursprung
Commit
e48c7ea331

+ 1 - 3
Assets/Scripts/Controller/Bicycle/RbBicycleController.cs

@@ -44,9 +44,7 @@ namespace Controller.Bicycle
             if (adjustSpeedToSlope){
                 previousSpeedAdjusted = currentSpeedAdjusted;
                 var boost = speedBooster.Boost;
-                float nextSpeedAdjusted;
-
-                nextSpeedAdjusted = CurrentSpeedSensed * speedBooster.Boost;
+                float nextSpeedAdjusted = CurrentSpeedSensed * speedBooster.Boost;
 
                 /*if (boost > 1 && CurrentSpeedSensed < 5.55f){ //5.55 m/s = 20 km/h
                     nextSpeedAdjusted = 5.55f * boost;

+ 8 - 3
Assets/Scripts/Controller/SensorBikeController.cs

@@ -27,11 +27,12 @@ namespace Controller
         public bool accelerate = true;
         public bool lean = true;
         public bool breaking = true;
-
+        public float brakeIncreasePerSecond = 2.5f;
+        
         private IBicycleController bicycleController;
         private bool isFrontWheelTrackerNotNull;
         private BikeSensorData sensorData;
-        private float brakeIncreasePerSecond = 2.5f;
+        
 
         private void Start()
         {
@@ -76,9 +77,13 @@ namespace Controller
         {
             if(breakData.isBreaking){
                 Debug.Log("Currently breaking");
-                bicycleController.CurrentBreakForce = brakeIncreasePerSecond * Time.deltaTime;
+                bicycleController.CurrentBreakForce += brakeIncreasePerSecond * Time.deltaTime;
                 //bicycleController.CurrentSpeed = Mathf.Max(0, bicycleController.CurrentSpeed - brakeIncreasePerSecond * Time.deltaTime);
             }
+            else
+            {
+                bicycleController.CurrentBreakForce = 0;
+            }
         }
     }
 }