fix(actor3D): fix checkGround not trying the right coordinate
This commit is contained in:
parent
30a0d59a41
commit
5f5b4da9c5
1 changed files with 5 additions and 5 deletions
|
@ -102,21 +102,21 @@ end
|
||||||
-- All functions related to gravity
|
-- All functions related to gravity
|
||||||
|
|
||||||
function Actor3D:applyGravity(dt)
|
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( )
|
self:checkGround( )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Actor3D:checkGround()
|
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)
|
local newx, newy, newz, cols, colNumber = self:checkCollision(dx, dy, dz)
|
||||||
|
|
||||||
for i, col in ipairs(cols) do
|
for i, col in ipairs(cols) do
|
||||||
if (col.type == "touch") or (col.type == "bounce") or (col.type == "slide") then
|
if (col.type == "touch") or (col.type == "bounce") or (col.type == "slide") then
|
||||||
if not (self.grav == 0) 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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue