Compare commits
No commits in common. "b978b821faf77e1d338fdd8e1dc4b852b1ba583d" and "558a1eda077874a12c9aa4918e33ca445b33f9ab" have entirely different histories.
b978b821fa
...
558a1eda07
@ -117,10 +117,10 @@ public partial class Clutch : PowertrainComponent
|
||||
ClutchInput = 1f;
|
||||
}
|
||||
|
||||
//if ( Controller.SwappedBrakes > 0 )
|
||||
//{
|
||||
// ClutchInput = 0;
|
||||
//}
|
||||
if ( Controller.SwappedBrakes > 0 )
|
||||
{
|
||||
ClutchInput = 0;
|
||||
}
|
||||
}
|
||||
if ( Controller.IsClutching > 0 )
|
||||
{
|
||||
@ -173,7 +173,7 @@ public partial class Clutch : PowertrainComponent
|
||||
OutputInertia = (inertiaSum + halfClutchInertia) * _clutchEngagement + halfClutchInertia;
|
||||
|
||||
// Allow the torque output to be only up to the slip torque valu
|
||||
float outputTorqueClamp = Controller.Engine.EstimatedPeakTorque * 1.5f * _clutchEngagement;
|
||||
float outputTorqueClamp = SlipTorque * _clutchEngagement;
|
||||
|
||||
OutputTorque = InputTorque;
|
||||
OutputTorque = Math.Clamp( OutputTorque, 0, outputTorqueClamp );
|
||||
|
||||
@ -34,8 +34,6 @@ public abstract partial class VeloXBase
|
||||
public float SwappedBrakes => IsInputSwapped ? Throttle : Brakes;
|
||||
|
||||
|
||||
public bool AnyInput => Throttle > 0 || Brakes > 0;
|
||||
|
||||
[Sync]
|
||||
public float VerticalInput
|
||||
{
|
||||
@ -108,11 +106,7 @@ public abstract partial class VeloXBase
|
||||
}
|
||||
protected void UpdateInput()
|
||||
{
|
||||
//VerticalInput = Input.AnalogMove.x;
|
||||
|
||||
Brakes = Input.Brake;
|
||||
Throttle = Input.Throttle;
|
||||
|
||||
VerticalInput = Input.AnalogMove.x;
|
||||
Handbrake = Input.Down( "Handbrake" ) ? 1 : 0;
|
||||
|
||||
SteeringAngle = Input.AnalogMove.y;
|
||||
|
||||
@ -42,12 +42,12 @@ public abstract partial class VeloXBase
|
||||
}
|
||||
else
|
||||
{
|
||||
v.BrakeTorque = SwappedBrakes * BrakeForce * 0.2f;
|
||||
v.BrakeTorque = SwappedBrakes * BrakeForce * 0.7f;
|
||||
v.BrakeTorque += Handbrake * HandbrakeForce;
|
||||
|
||||
}
|
||||
|
||||
if ( TotalSpeed < 1 && !AnyInput )
|
||||
if ( TotalSpeed < 1 && Input.AnalogMove.x == 0 )
|
||||
{
|
||||
v.BrakeTorque = HandbrakeForce;
|
||||
}
|
||||
|
||||
@ -249,14 +249,11 @@ public partial class VeloXWheel
|
||||
{
|
||||
lowSpeedReferenceIsSet = false;
|
||||
}
|
||||
|
||||
|
||||
ForwardFriction.Force = Math.Clamp( ForwardFriction.Force, -peakForwardFrictionForce, peakForwardFrictionForce );
|
||||
|
||||
SidewayFriction.Force = Math.Clamp( SidewayFriction.Force, -peakSideFrictionForce, peakSideFrictionForce );
|
||||
|
||||
|
||||
if ( absForwardSpeed > 0.01f || absAngularVelocity > 0.01f )
|
||||
if ( absForwardSpeed > 2f || absAngularVelocity > 4f )
|
||||
{
|
||||
|
||||
float forwardSlipPercent = ForwardFriction.Slip / Tire.GetPeakSlip();
|
||||
@ -264,7 +261,7 @@ public partial class VeloXWheel
|
||||
float slipCircleLimit = MathF.Sqrt( forwardSlipPercent * forwardSlipPercent + sideSlipPercent * sideSlipPercent );
|
||||
if ( slipCircleLimit > 1f )
|
||||
{
|
||||
float beta = MathF.Atan2( sideSlipPercent, forwardSlipPercent * 1.05f );
|
||||
float beta = MathF.Atan2( sideSlipPercent, forwardSlipPercent * 0.9f );
|
||||
float sinBeta = MathF.Sin( beta );
|
||||
float cosBeta = MathF.Cos( beta );
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Sandbox;
|
||||
using System;
|
||||
|
||||
namespace VeloX;
|
||||
|
||||
|
||||
@ -61,7 +61,6 @@ public partial class VeloXWheel : Component
|
||||
internal void Update( VeloXBase vehicle, in float dt )
|
||||
{
|
||||
UpdateVisuals( vehicle, dt );
|
||||
|
||||
}
|
||||
|
||||
private void UpdateVisuals( VeloXBase vehicle, in float dt )
|
||||
|
||||
@ -40,7 +40,7 @@ public partial class VeloXCar
|
||||
_sideArea = Dimensions.y * Dimensions.z * 0.8f;
|
||||
_forwardSpeed = LocalVelocity.x.InchToMeter();
|
||||
_sideSpeed = LocalVelocity.y.InchToMeter();
|
||||
longitudinalDragForce = 2 * RHO * _frontalArea * FrontalCd * (_forwardSpeed * _forwardSpeed) * (_forwardSpeed > 0 ? -1f : 1f);
|
||||
longitudinalDragForce = 0.5f * RHO * _frontalArea * FrontalCd * (_forwardSpeed * _forwardSpeed) * (_forwardSpeed > 0 ? -1f : 1f);
|
||||
lateralDragForce = 0.5f * RHO * _sideArea * SideCd * (_sideSpeed * _sideSpeed) * (_sideSpeed > 0 ? -1f : 1f);
|
||||
var force = new Vector3( longitudinalDragForce.MeterToInch(), lateralDragForce.MeterToInch(), 0 ).RotateAround( Vector3.Zero, WorldRotation );
|
||||
Body.ApplyForce( force );
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using Sandbox;
|
||||
|
||||
namespace VeloX;
|
||||
|
||||
public class InputResolver
|
||||
{
|
||||
public Connection Driver { get; internal set; }
|
||||
@ -31,27 +30,6 @@ public class InputResolver
|
||||
return IsDriverActive && Input.Down( action );
|
||||
}
|
||||
|
||||
public float Brake
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Input.UsingController )
|
||||
return Input.GetAnalog( InputAnalog.LeftTrigger );
|
||||
|
||||
return Input.Down( "Brake" ) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
public float Throttle
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( Input.UsingController )
|
||||
return Input.GetAnalog( InputAnalog.RightTrigger );
|
||||
|
||||
return Input.Down( "Throttle" ) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Pressed( string action )
|
||||
{
|
||||
return IsDriverActive && Input.Pressed( action );
|
||||
@ -62,11 +40,6 @@ public class InputResolver
|
||||
return IsDriverActive && Input.Released( action );
|
||||
}
|
||||
|
||||
public float GetAnalog( InputAnalog analog )
|
||||
{
|
||||
return IsDriverActive ? Input.GetAnalog( analog ) : 0f;
|
||||
}
|
||||
|
||||
public void TriggerHaptics( float leftMotor, float rightMotor, float leftTrigger = 0f, float rightTrigger = 0f, int duration = 500 )
|
||||
{
|
||||
if ( IsDriverActive )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user