Marcel Zickler 3 years ago
parent
commit
3e1bf2b34c

+ 1 - 1
Assets/Scenes/MainScene.unity

@@ -245728,7 +245728,7 @@ PrefabInstance:
     - target: {fileID: 3450098086302837850, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}
       propertyPath: maxSpeed
-      value: 4.62
+      value: 11.111
       objectReference: {fileID: 0}
     - target: {fileID: 4988978072042319891, guid: 3b07d6594636ab04d9c1fac04c1cde7e,
         type: 3}

+ 13 - 11
Assets/Scripts/Controller/Bicycle/RbBicycleController.cs

@@ -60,28 +60,30 @@ namespace Controller.Bicycle
         private void FixedUpdate()
         {
             ApplyVelocity();
+            ApplySteerAngleAndRotation();
         }
 
         private void ApplyVelocity()
         {
-            var targetVelocity = new Vector3(CalculateVelocityX(), 0, CurrentSpeed);
+            var targetVelocity = new Vector3(0, 0, CurrentSpeed);
             targetVelocity = rbTransform.TransformDirection(targetVelocity);
             var velocityChange = targetVelocity - rigidBody.velocity;
             velocityChange.y = 0;
             rigidBody.AddForce(velocityChange, ForceMode.VelocityChange);
         }
 
-        private float CalculateVelocityX()
-        {
-            var previousRotation = rbTransform.localRotation.eulerAngles;
-            rbTransform.localRotation =
-                Quaternion.Euler(previousRotation + new Vector3(0, CurrentSteerAngle, 0) * Time.fixedDeltaTime);
-            return 0;
-            //return CurrentSteerAngle/4; //TODO: something a bit smarter
-        }
-
-        private void ApplyLeaningAngle()
+        private void ApplySteerAngleAndRotation()
         {
+            if (controllerMode == BicycleControllerMode.Independent)
+            {
+                var r = rbTransform.localRotation.eulerAngles;
+                rbTransform.localRotation = Quaternion.Euler(r + new Vector3(0, CurrentSteerAngle, -CurrentLeaningAngle) * Time.fixedDeltaTime);
+                
+            }else if (controllerMode == BicycleControllerMode.LeaningAngleDependentOnSteerAngle)
+            {
+                //TODO
+            }
+          
         }
     }
 }