assets and etc.
This commit is contained in:
@@ -102,20 +102,25 @@ public partial class Clutch : PowertrainComponent
|
||||
// Clutch engagement calculation for automatic clutch
|
||||
else
|
||||
{
|
||||
|
||||
// Calculate engagement
|
||||
// Engage the clutch if the input spinning faster than the output, but also if vice versa.
|
||||
float throttleInput = Controller.SwappedThrottle;
|
||||
float finalEngagementRPM = EngagementRPM + ThrottleEngagementOffsetRPM * (throttleInput * throttleInput);
|
||||
float finalEngagementRPM = 500 + ThrottleEngagementOffsetRPM * (throttleInput * throttleInput);
|
||||
float referenceRPM = MathF.Max( InputRPM, OutputRPM );
|
||||
|
||||
ClutchInput = (referenceRPM - finalEngagementRPM) / EngagementRange;
|
||||
ClutchInput = Math.Clamp( ClutchInput, 0f, 1f );
|
||||
|
||||
// Avoid disconnecting clutch at high speed
|
||||
if ( engine.OutputRPM > engine.IdleRPM * 1.1f && Controller.TotalSpeed > 3f )
|
||||
{
|
||||
ClutchInput = 1f;
|
||||
}
|
||||
|
||||
if ( Controller.SwappedBrakes > 0 )
|
||||
{
|
||||
ClutchInput = 0;
|
||||
}
|
||||
}
|
||||
if ( Controller.IsClutching > 0 )
|
||||
{
|
||||
@@ -175,13 +180,14 @@ public partial class Clutch : PowertrainComponent
|
||||
float slipOverflowTorque = -Math.Min( outputTorqueClamp - OutputTorque, 0 );
|
||||
|
||||
// Apply the creep torque commonly caused by torque converter drag in automatic transmissions
|
||||
ApplyCreepTorque( ref OutputTorque, CreepTorque );
|
||||
//ApplyCreepTorque( ref OutputTorque, CreepTorque );
|
||||
|
||||
// Send the torque downstream
|
||||
float returnTorque = _output.ForwardStep( OutputTorque, OutputInertia, dt ) * _clutchEngagement;
|
||||
|
||||
|
||||
// Clamp the return torque to the slip torque of the clutch once again
|
||||
returnTorque = Math.Clamp( returnTorque, -SlipTorque, SlipTorque );
|
||||
//returnTorque = Math.Clamp( returnTorque, -SlipTorque, SlipTorque );
|
||||
|
||||
// Torque returned to the input is a combination of torque returned by the powertrain and the torque that
|
||||
// was possibly never sent downstream
|
||||
|
||||
@@ -250,7 +250,7 @@ public class Engine : PowertrainComponent, IScenePhysicsEvents
|
||||
while ( startTimer <= StartDuration && StarterActive )
|
||||
{
|
||||
startTimer += 0.1f;
|
||||
await GameTask.DelaySeconds( 0.1f );
|
||||
await Task.DelaySeconds( 0.1f );
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -341,7 +341,7 @@ public class Engine : PowertrainComponent, IScenePhysicsEvents
|
||||
// Calculate/get torque returned from wheels
|
||||
|
||||
OutputTorque = generatedTorque - reactionTorque;
|
||||
float returnTorque = -ForwardStep( OutputTorque, 0, dt );
|
||||
float returnTorque = ForwardStep( OutputTorque, 0, dt );
|
||||
|
||||
float totalTorque = generatedTorque + returnTorque + reactionTorque;
|
||||
OutputAngularVelocity += totalTorque / inertiaSum * dt;
|
||||
@@ -367,7 +367,7 @@ public class Engine : PowertrainComponent, IScenePhysicsEvents
|
||||
|
||||
RevLimiterActive = true;
|
||||
OnRevLimiter?.Invoke();
|
||||
await GameTask.DelayRealtimeSeconds( RevLimiterCutoffDuration );
|
||||
await Task.DelayRealtimeSeconds( RevLimiterCutoffDuration );
|
||||
RevLimiterActive = false;
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ public class Engine : PowertrainComponent, IScenePhysicsEvents
|
||||
// Apply idle throttle correction to keep the engine running
|
||||
else
|
||||
ApplyICEIdleCorrection();
|
||||
|
||||
|
||||
// Trigger rev limiter if needed
|
||||
if ( angularVelocity >= _revLimiterAngularVelocity && !RevLimiterActive )
|
||||
RevLimiter();
|
||||
|
||||
@@ -548,7 +548,7 @@ public class Transmission : PowertrainComponent
|
||||
{
|
||||
ShiftProgress = shiftTimer / ShiftDuration;
|
||||
shiftTimer += dt;
|
||||
await GameTask.DelayRealtimeSeconds( dt );
|
||||
await Task.DelayRealtimeSeconds( dt );
|
||||
}
|
||||
|
||||
// Do the shift at the half point of shift duration
|
||||
@@ -566,7 +566,7 @@ public class Transmission : PowertrainComponent
|
||||
{
|
||||
ShiftProgress = shiftTimer / ShiftDuration;
|
||||
shiftTimer += dt;
|
||||
await GameTask.DelayRealtimeSeconds( dt );
|
||||
await Task.DelayRealtimeSeconds( dt );
|
||||
}
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ public class Transmission : PowertrainComponent
|
||||
while ( postShiftBanTimer < PostShiftBan )
|
||||
{
|
||||
postShiftBanTimer += dt;
|
||||
await GameTask.DelayRealtimeSeconds( dt );
|
||||
await Task.DelayRealtimeSeconds( dt );
|
||||
}
|
||||
|
||||
// Post shift ban has finished
|
||||
|
||||
@@ -15,10 +15,8 @@ public partial class WheelPowertrain : PowertrainComponent
|
||||
protected override void OnStart()
|
||||
{
|
||||
_initialRollingResistance = Wheel.RollingResistanceTorque;
|
||||
_initialWheelInertia = Wheel.BaseInertia;
|
||||
}
|
||||
private float _initialRollingResistance;
|
||||
private float _initialWheelInertia;
|
||||
|
||||
public override float QueryAngularVelocity( float angularVelocity, float dt )
|
||||
{
|
||||
@@ -48,7 +46,7 @@ public partial class WheelPowertrain : PowertrainComponent
|
||||
OutputTorque = InputTorque;
|
||||
OutputInertia = Wheel.BaseInertia + inertiaSum;
|
||||
|
||||
Wheel.Torque = OutputTorque;
|
||||
Wheel.DriveTorque = OutputTorque;
|
||||
Wheel.Inertia = OutputInertia;
|
||||
|
||||
Wheel.AutoSimulate = false;
|
||||
@@ -56,4 +54,14 @@ public partial class WheelPowertrain : PowertrainComponent
|
||||
|
||||
return Math.Abs( Wheel.CounterTorque );
|
||||
}
|
||||
|
||||
protected override void DrawGizmos()
|
||||
{
|
||||
|
||||
if ( !Gizmo.IsSelected )
|
||||
return;
|
||||
Gizmo.Transform = Wheel.WorldTransform;
|
||||
Wheel?.GizmoDraw();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user