From 5f5b4da9c520c7f0042e6e584ebd2d93ef76827d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 30 Jun 2019 22:04:30 +0200 Subject: [PATCH] fix(actor3D): fix checkGround not trying the right coordinate --- gamecore/modules/world/actors/actor3D.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gamecore/modules/world/actors/actor3D.lua b/gamecore/modules/world/actors/actor3D.lua index 2ae451f..1cb4d3a 100644 --- a/gamecore/modules/world/actors/actor3D.lua +++ b/gamecore/modules/world/actors/actor3D.lua @@ -102,21 +102,21 @@ end -- All functions related to gravity function Actor3D:applyGravity(dt) - self.zsp = self.zsp - (self.grav * dt) + local grav = self.grav * -1 + self.zsp = self.zsp + (grav * dt) - if utils.math.sign(self.zsp) == utils.math.sign(self.grav) then + if utils.math.sign(self.zsp) == utils.math.sign(grav) then self:checkGround( ) end end function Actor3D:checkGround() - local dx, dy, dz = self.x, self.y, self.z + utils.math.sign(self.grav) + local dx, dy, dz = self.x, self.y, self.z - utils.math.sign(self.grav) local newx, newy, newz, cols, colNumber = self:checkCollision(dx, dy, dz) - for i, col in ipairs(cols) do if (col.type == "touch") or (col.type == "bounce") or (col.type == "slide") then if not (self.grav == 0) then - if col.normal.z ~= utils.math.sign(self.grav) then self.onGround = true end + if col.normal.z == utils.math.sign(self.grav) then self.onGround = true end end end end