Explorar o código

GamepadBikeController adjustments

Marcel Zickler %!s(int64=4) %!d(string=hai) anos
pai
achega
544ebe3635
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      Assets/Scripts/Controller/GamepadBikeController.cs

+ 3 - 1
Assets/Scripts/Controller/GamepadBikeController.cs

@@ -17,6 +17,7 @@ namespace Controller
         public float leanMultiplier = 20f;
         public float steerMultiplier = 15f;
 
+        private float accelerationLoss = 0.5f;
         private float acceleration;
         private float lean;
         private float steer;
@@ -31,13 +32,14 @@ namespace Controller
         {
             if (useSteer) bicycleController.CurrentSteerAngle = steer;
             if (useLean) bicycleController.CurrentLeaningAngle = lean;
-            if (useSpeed) bicycleController.CurrentSpeed += acceleration;
+            if (useSpeed) bicycleController.CurrentSpeed += acceleration * Time.deltaTime;
         }
 
         [UsedImplicitly]
         public void OnSpeed(InputValue value)
         {
             acceleration = value.Get<float>() * speedMultiplier;
+            if (acceleration < 0.1f && acceleration >= 0) acceleration = -accelerationLoss;
         }
 
         [UsedImplicitly]