Skip to content

Commit

Permalink
100% clutch engagement
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyunge committed Apr 17, 2024
1 parent 3a88013 commit 05e9388
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lua/entities/acf_engine_update/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ function ENT:CalcRPM(SelfTbl)
end
if ( GearboxCount > 0 ) then
GearboxRPM = GearboxRPM / GearboxCount
GearboxLoad = GearboxLoad / GearboxCount
GearboxLoad = GearboxLoad / GearboxCount
end

-- Calculate Engine Vacuum
Expand All @@ -796,9 +796,16 @@ function ENT:CalcRPM(SelfTbl)
local EngineSpeed = ( EngineSpeed_NoLoad * ( 1 - GearboxLoad ) ) + ( EngineSpeed_Loaded * GearboxLoad )

-- Apply Engine Speed To The Flywheel
SelfTbl.FlyRPM = SelfTbl.FlyRPM + EngineSpeed * (DeltaTime / DefaultTick)
if math.abs(SpeedDifference) <= 200 and GearboxLoad == 1 then
-- Consider the engine fully engaged with gearbox
SelfTbl.FlyRPM = GearboxRPM
else
-- Solve speed difference
SelfTbl.FlyRPM = SelfTbl.FlyRPM + EngineSpeed * (DeltaTime / DefaultTick)
end
SelfTbl.FlyRPM = max( 0, SelfTbl.FlyRPM )


SelfTbl.FlywheelInertiaTorque = (SelfTbl.FlyRPM - SelfTbl.SpeedChange) / 60
SelfTbl.SpeedChange = SelfTbl.FlyRPM

Expand Down

0 comments on commit 05e9388

Please sign in to comment.