crazy braking
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user