fix: only apply friction if it's > 0

This commit is contained in:
Kazhnuz 2021-11-25 11:34:25 +01:00
parent f0819dd815
commit 9aa19dfa30

View file

@ -54,12 +54,18 @@ function PhysicalActor:getFuturePosition(dt)
end end
function PhysicalActor:applyFriction(dt) function PhysicalActor:applyFriction(dt)
if (self.xfrc > 0) then
self.xsp = utils.math.toZero(self.xsp, self.xfrc * dt) self.xsp = utils.math.toZero(self.xsp, self.xfrc * dt)
end
if (self.yfrc > 0) then
self.ysp = utils.math.toZero(self.ysp, self.yfrc * dt) self.ysp = utils.math.toZero(self.ysp, self.yfrc * dt)
end
if (self.z ~= nil) then if (self.z ~= nil) then
if (self.zfrc > 0) then
self.zsp = utils.math.toZero(self.zsp, self.zfrc * dt) self.zsp = utils.math.toZero(self.zsp, self.zfrc * dt)
end end
end end
end
function PhysicalActor:solveAllCollisions(cols) function PhysicalActor:solveAllCollisions(cols)
for i, col in ipairs(cols) do for i, col in ipairs(cols) do