This commit is contained in:
2023-05-22 22:35:45 +03:00
parent 97403a249a
commit d1c446b598
2 changed files with 18 additions and 10 deletions

View File

@@ -18,6 +18,8 @@ function Wheel:initialize(vehicle, name, config)
self.brakePower = config.BrakePower or 0
self.handbrakePower = config.HandbrakePower or 0
self.rotationAxle = config.RotationAxle or Angle(0, 0, 1)
self.wireInputs = {
[self.name] = 'entity'
}
@@ -52,6 +54,11 @@ function Wheel:initialize(vehicle, name, config)
end
end
end)
local right = self.entity:getRight()
local offsetRight = self.entity:getRight():rotateAroundAxis(self.entity:getUp(), self.offset)
self.dir = right:dot(offsetRight)
end
function Wheel:getEntityRadius()
@@ -70,7 +77,7 @@ function Wheel:createHolo(entity)
local holo = holograms.create(
entity:getPos(),
entity:getAngles() + Angle(0, self.offset, 0),
self.CONFIG.Model or 'models/sprops/trans/wheel_b/t_wheel15.mdl'
self.CONFIG.Model or ''
)
holo:setParent(entity)
@@ -115,9 +122,10 @@ function Wheel:forwardStep(torque, inertia)
end
if isValid(self.holo) then
self.rot = self.rot + math.deg(self.angularVelocity) * TICK_INTERVAL
self.rot = self.rot + math.deg(self.angularVelocity) * TICK_INTERVAL * self.dir
local angle = self.entity:localToWorldAngles(Angle(0, self.offset - self.customWheel.steerAngle, self.rot))
local steerAngle = self.entity:localToWorldAngles(Angle(0, self.offset - self.customWheel.steerAngle, 0) + self.rotationAxle * self.rot)
local angle = steerAngle
self.holo:setAngles(angle)
end