Closed nottirb closed 2 years ago
Hmm, yeah might be a limitation running a dt that high. There are already measures in place that should have prevented this - I'll check it out.
Something you might look into is separating your physics calculations from your render calculations. I do something like this for physics that is not easily calculatable without using dt. I have not looked into your internals, though I thought it might still be worth mentioning.
(PHYSICS_SPEED is effectively your dt now)
function Class:getPosition(t: number): Vector3
-- update physics
local clockDiff = t - self._t0
local newPhysicsClock = self._t0 + (clockDiff - clockDiff % PHYSICS_SPEED) + PHYSICS_SPEED
while newPhysicsClock > self.nextPhysicsClock + 0.001 do
-- do physics update calculations
-- example:
local newPosition = self.targetPosition + PHYSICS_SPEED * self.velocity
self.position = self.targetPosition
self.targetPosition = newPosition
self.nextPhysicsClock += PHYSICS_SPEED
end
self.nextPhysicsClock = newPhysicsClock
self.physicsClock = self.nextPhysicsClock - PHYSICS_SPEED
-- calculate render position
local alpha = (t - self.physicsClock) / (self.nextPhysicsClock - self.physicsClock)
return self.position + (self.targetPosition - self.position) * alpha
end
This is resolved now. Player physics is synced to 60fps regardless of your framerate, plus a bit of extra polish to make it "resync" if your fps is basically a perfect 60.
Capping my fps to 1-3 fps lets me jump 2x as high and launch x2 as far on the pads. Can easily be exploited by a cheater implementing a fake lag/fps switch.