Reworking vehicle controller
This commit is contained in:
@@ -38,11 +38,15 @@ function Clutch:getOutputs()
|
||||
}
|
||||
end
|
||||
|
||||
function Clutch:update()
|
||||
if self._gearbox.type == gearboxTypes.MANUAL then
|
||||
self.press = wire.ports.Clutch
|
||||
function Clutch:getPress()
|
||||
if self._gearbox ~= nil and self._gearbox.type == gearboxTypes.MANUAL then
|
||||
return wire.ports.Clutch
|
||||
else
|
||||
return self.press
|
||||
end
|
||||
end
|
||||
|
||||
function Clutch:update()
|
||||
local someConversionCoeff = 0.10472
|
||||
|
||||
local engRPM = self._engine and self._engine.rpm or 0
|
||||
@@ -51,7 +55,7 @@ function Clutch:update()
|
||||
local gboxRatioNotZero = gboxRatio ~= 0 and 1 or 0
|
||||
|
||||
self.slip = ((engRPM - gboxRPM) * someConversionCoeff) * gboxRatioNotZero / 2
|
||||
self.targetTorque = math.clamp(self.slip * self.stiffness * (1 - self.press), -self.maxTorque, self.maxTorque)
|
||||
self.targetTorque = math.clamp(self.slip * self.stiffness * (1 - self:getPress()), -self.maxTorque, self.maxTorque)
|
||||
|
||||
self.torque = math.lerp(self.damping, self.torque, self.targetTorque)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user