Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ProfessorBoxtrot opened this issue Jul 20, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@ProfessorBoxtrot
Copy link

ProfessorBoxtrot commented Jul 20, 2022

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

@ProfessorBoxtrot ProfessorBoxtrot added the bug Something isn't working label Jul 20, 2022
@CheezusChrust
Copy link
Contributor

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.

@ProfessorBoxtrot
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants