update
This commit is contained in:
parent
97403a249a
commit
d1c446b598
@ -9,10 +9,10 @@ local Vehicle, POWERTRAIN_COMPONENT = unpack(require('/koptilnya/engine_remaster
|
|||||||
local WheelConfig = {
|
local WheelConfig = {
|
||||||
BrakePower = 800,
|
BrakePower = 800,
|
||||||
CustomWheel = {},
|
CustomWheel = {},
|
||||||
Offset = 180,
|
Model = 'models/sprops/trans/wheel_d/t_wheel25.mdl',
|
||||||
Model = 'models/sprops/trans/wheel_d/t_wheel25.mdl'
|
RotationAxle = Angle(1, 0, 0)
|
||||||
}
|
}
|
||||||
local FrontWheelsConfig = table.merge(table.copy(WheelConfig), { SteerLock = 10 })
|
local FrontWheelsConfig = table.merge(table.copy(WheelConfig), { SteerLock = 35 })
|
||||||
local RearWheelsConfig = table.merge(table.copy(WheelConfig), { HandbrakePower = 2000 })
|
local RearWheelsConfig = table.merge(table.copy(WheelConfig), { HandbrakePower = 2000 })
|
||||||
|
|
||||||
Vehicle:new({
|
Vehicle:new({
|
||||||
@ -75,22 +75,22 @@ Vehicle:new({
|
|||||||
Name = 'WheelFL',
|
Name = 'WheelFL',
|
||||||
Input = 'Axle1',
|
Input = 'Axle1',
|
||||||
Type = POWERTRAIN_COMPONENT.Wheel,
|
Type = POWERTRAIN_COMPONENT.Wheel,
|
||||||
Config = FrontWheelsConfig
|
Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 0 })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = 'WheelFR',
|
Name = 'WheelFR',
|
||||||
Input = 'Axle1',
|
Input = 'Axle1',
|
||||||
Type = POWERTRAIN_COMPONENT.Wheel,
|
Type = POWERTRAIN_COMPONENT.Wheel,
|
||||||
Config = FrontWheelsConfig
|
Config = table.merge(table.copy(FrontWheelsConfig), { Offset = 180 })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = 'WheelRL',
|
Name = 'WheelRL',
|
||||||
Type = POWERTRAIN_COMPONENT.Wheel,
|
Type = POWERTRAIN_COMPONENT.Wheel,
|
||||||
Config = RearWheelsConfig
|
Config = table.merge(table.copy(RearWheelsConfig), { Offset = 0 })
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = 'WheelRR',
|
Name = 'WheelRR',
|
||||||
Type = POWERTRAIN_COMPONENT.Wheel,
|
Type = POWERTRAIN_COMPONENT.Wheel,
|
||||||
Config = RearWheelsConfig
|
Config = table.merge(table.copy(RearWheelsConfig), { Offset = 180 })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -18,6 +18,8 @@ function Wheel:initialize(vehicle, name, config)
|
|||||||
self.brakePower = config.BrakePower or 0
|
self.brakePower = config.BrakePower or 0
|
||||||
self.handbrakePower = config.HandbrakePower or 0
|
self.handbrakePower = config.HandbrakePower or 0
|
||||||
|
|
||||||
|
self.rotationAxle = config.RotationAxle or Angle(0, 0, 1)
|
||||||
|
|
||||||
self.wireInputs = {
|
self.wireInputs = {
|
||||||
[self.name] = 'entity'
|
[self.name] = 'entity'
|
||||||
}
|
}
|
||||||
@ -52,6 +54,11 @@ function Wheel:initialize(vehicle, name, config)
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function Wheel:getEntityRadius()
|
function Wheel:getEntityRadius()
|
||||||
@ -70,7 +77,7 @@ function Wheel:createHolo(entity)
|
|||||||
local holo = holograms.create(
|
local holo = holograms.create(
|
||||||
entity:getPos(),
|
entity:getPos(),
|
||||||
entity:getAngles() + Angle(0, self.offset, 0),
|
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)
|
holo:setParent(entity)
|
||||||
|
|
||||||
@ -115,9 +122,10 @@ function Wheel:forwardStep(torque, inertia)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if isValid(self.holo) then
|
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)
|
self.holo:setAngles(angle)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user