This commit is contained in:
2025-11-18 21:53:51 +07:00
parent 97fcb29bc0
commit bbc479be33
11 changed files with 152 additions and 42 deletions

View File

@@ -543,13 +543,14 @@ public class Transmission : PowertrainComponent
// Run the first half of shift timer
float shiftTimer = 0;
float halfDuration = ShiftDuration * 0.5f;
if ( !instant )
while ( shiftTimer < halfDuration )
{
ShiftProgress = shiftTimer / ShiftDuration;
shiftTimer += dt;
await Task.DelayRealtimeSeconds( dt );
}
//if ( !instant )
// while ( shiftTimer < halfDuration )
// {
// ShiftProgress = shiftTimer / ShiftDuration;
// shiftTimer += dt;
// await Task.DelayRealtimeSeconds( dt );
// }
// Do the shift at the half point of shift duration
Gear = targetGear;
@@ -603,28 +604,28 @@ public class Transmission : PowertrainComponent
float brakeInput = car.SwappedBrakes;
int currentGear = Gear;
// Assign base shift points
_targetDownshiftRPM = _downshiftRPM;
_targetUpshiftRPM = _upshiftRPM;
_targetDownshiftRPM = car.Engine.EstimatedPeakPowerRPM - 2000;
_targetUpshiftRPM = car.Engine.EstimatedPeakPowerRPM;
// Calculate shift points for variable shift RPM
if ( VariableShiftPoint )
{
// Smooth throttle input so that the variable shift point does not shift suddenly and cause gear hunting
_smoothedThrottleInput = MathX.Lerp( _smoothedThrottleInput, throttleInput, Time.Delta * 2f );
float revLimiterRPM = car.Engine.RevLimiterRPM;
//if ( VariableShiftPoint )
//{
// // Smooth throttle input so that the variable shift point does not shift suddenly and cause gear hunting
// _smoothedThrottleInput = MathX.Lerp( _smoothedThrottleInput, throttleInput, Time.Delta * 2f );
// float revLimiterRPM = car.Engine.RevLimiterRPM;
_targetUpshiftRPM = _upshiftRPM + Math.Clamp( _smoothedThrottleInput * VariableShiftIntensity, 0f, 1f ) * _upshiftRPM;
_targetUpshiftRPM = Math.Clamp( _targetUpshiftRPM, _upshiftRPM, revLimiterRPM * 0.97f );
// _targetUpshiftRPM = _upshiftRPM + Math.Clamp( _smoothedThrottleInput * VariableShiftIntensity, 0f, 1f ) * _upshiftRPM;
// _targetUpshiftRPM = Math.Clamp( _targetUpshiftRPM, _upshiftRPM, revLimiterRPM * 0.97f );
_targetDownshiftRPM = _downshiftRPM + Math.Clamp( _smoothedThrottleInput * VariableShiftIntensity, 0f, 1f ) * _downshiftRPM;
_targetDownshiftRPM = Math.Clamp( _targetDownshiftRPM, car.Engine.IdleRPM * 1.1f, _targetUpshiftRPM * 0.7f );
// _targetDownshiftRPM = _downshiftRPM + Math.Clamp( _smoothedThrottleInput * VariableShiftIntensity, 0f, 1f ) * _downshiftRPM;
// _targetDownshiftRPM = Math.Clamp( _targetDownshiftRPM, car.Engine.IdleRPM * 1.1f, _targetUpshiftRPM * 0.7f );
// Add incline modifier
float inclineModifier = Math.Clamp( car.WorldRotation.Forward.Dot( Vector3.Up ) * InclineEffectCoeff, 0f, 1f );
// // Add incline modifier
// float inclineModifier = Math.Clamp( car.WorldRotation.Forward.Dot( Vector3.Up ) * InclineEffectCoeff, 0f, 1f );
_targetUpshiftRPM += revLimiterRPM * inclineModifier;
_targetDownshiftRPM += revLimiterRPM * inclineModifier;
}
// _targetUpshiftRPM += revLimiterRPM * inclineModifier;
// _targetDownshiftRPM += revLimiterRPM * inclineModifier;
//}
// In neutral