crazy braking

This commit is contained in:
2024-04-05 12:31:05 +02:00
parent 7dfa783aac
commit 5d88ed4faf
2 changed files with 8 additions and 412 deletions

View File

@@ -54,9 +54,7 @@ public class carcontrolv2 : MonoBehaviour
bool isStopping = vInput == 0; // range
bool isBraking = vInput < 0 && forwardSpeed > 0;
Debug.Log(vInput);
bool isBraking = (vInput < 0 && forwardSpeed > 0) || (vInput > 0 && forwardSpeed < 0);
foreach (var wheel in wheels)
{
@@ -87,6 +85,12 @@ public class carcontrolv2 : MonoBehaviour
// If the user is trying to go in the opposite direction
// apply brakes to all wheels
wheel.WheelCollider.brakeTorque = Mathf.Abs(vInput) * brakeTorque + autoBrake;
if (forwardSpeed < 0)
{
wheel.WheelCollider.brakeTorque = (Mathf.Abs(vInput) * brakeTorque + autoBrake) * 5;
}
// wheel.WheelCollider.motorTorque = 0;
}
}