ACF-Team / ACF-3

ACF
MIT License
69 stars 56 forks source link

[BUG] Gearboxes will output 0 torque most of the time when powering light props #309

Open shroobloom opened 2 years ago

shroobloom commented 2 years ago

Short Description

It seems that when a gearbox is powering a light prop (<200-ish?), it will not apply any torque unless the prop dips below a certain RPM. The source of the issue is on entities/gearbox/init.lua on line 800:

for Wheel, Link in pairs(self.Wheels) do
    local RPM = CalcWheel(self, Link, Wheel, SelfWorld)

    Link.ReqTq = 0

    if self.GearRatio ~= 0 then
        local Clutch = Link.Side == 0 and self.LClutch or self.RClutch
        local OnRPM = ((InputRPM > 0 and RPM < InputRPM) or (InputRPM < 0 and RPM > InputRPM))

        if Clutch > 0 and OnRPM then

            local Multiplier = 1
            if self.DoubleDiff and self.SteerRate ~= 0 then
                local Rate = self.SteerRate * 2

                -- this actually controls the RPM of the wheels, so the steering rate is correct
                if Link.Side == 0 then
                    Multiplier = math.min(0, Rate) + 1
                else
                    Multiplier = -math.max(0, Rate) + 1
                end
            end

            Link.ReqTq = (InputRPM * Multiplier - RPM) * InputInertia * Clutch

            self.TotalReqTq = self.TotalReqTq + math.abs(Link.ReqTq)
        end
    end
end

OnRPM returns false and Link.ReqTq is set to 0, applying no torque to its attached wheels.

Branch and Version

Master, up to date as of posting this.

How to Reproduce

Link a light prop up to an engine, and it will start to spin erratically.

Screenshots/Additional Information

I was able to replicate this bug with 3 vehicles: image I can provide the dupe files if needed. None of them switch gears or use brake/clutch/steer, the only gearboxes in use are differentials and double differentials, but the issue seems to happen for any gearbox.

Video of the tank: https://youtu.be/NG4omZTKJPo

Video of the quadcopter: (much more dramatic) https://youtu.be/jy6cHfwHfRU

CheezusChrust commented 2 years ago

Related to/same issue as #134, it's been talked about and most likely would need an overhaul of the whole mobility system to fix this easily. Hopefully it's looked into soon.

shroobloom commented 2 years ago

Ah, somehow I missed that when looking over issues. Hopefully this should still provide some more insight on the problem.