fix(physics): amelioration gestion coordonnées

This commit is contained in:
Kazhnuz 2024-11-08 09:42:44 +01:00
parent de5cc096b8
commit 3bd966953d
2 changed files with 10 additions and 7 deletions

View file

@ -80,13 +80,12 @@ function Actor:drawShadow()
if (self.world.type ~= "3D" and self.world.drawShadow ~= true) then
return
end
local shadowZ = self:getGroundZ()
if (shadowZ == nil) then
if (self.zGround == nil) then
return
end
local r, g, b, a = love.graphics.getColor( )
local x, y = self.position.x + (self.dimensions.w / 2), self.position.y + (3 * self.dimensions.h / 4) - shadowZ
local x, y = self.position.x + (self.dimensions.w / 2), self.position.y + (3 * self.dimensions.h / 4) - self.zGround
love.graphics.setColor(0, 0, 0, .3)
love.graphics.ellipse( "fill", math.floor(x), math.floor(y), self.dimensions.w / 2, self.dimensions.w / 4 )
love.graphics.setColor(r, g, b, a)

View file

@ -141,6 +141,11 @@ function Physics:applyMovement(dt)
-- Les autres hitboxes traverses tout
self:applyHitboxesCollisions(function(item, other) return "cross" end)
if (self.visual ~= nil) then
self:getGroundZ()
self.world:updateShape(self)
end
end
function Physics:move(position)
@ -148,9 +153,6 @@ function Physics:move(position)
if (self.isDestroyed == false) then
self.position, cols, colNumber = self.mainHitbox:checkCollisionAtPoint(position, self.filter)
self.mainHitbox:updatePosition()
if (self.visual ~= nil) then
self.world:updateShape(self)
end
end
return self.position, cols, colNumber
@ -202,7 +204,9 @@ function Physics:getGroundZ()
end
end
end
return z
if (z ~= nil) then
self.zGround = math.floor(z)
end
end
function Physics:_applyCollisionResponses(col)