feat(physics): add support for multiple hitboxes responses
This commit is contained in:
parent
28305faf42
commit
e40683a6b0
1 changed files with 7 additions and 1 deletions
|
@ -138,6 +138,9 @@ function Physics:applyMovement(dt)
|
|||
self:solveAllCollisions(cols)
|
||||
|
||||
self.speed = physicsUtils.applyFriction(self.speed, self.friction * dt)
|
||||
|
||||
-- Les autres hitboxes traverses tout
|
||||
self:applyHitboxesCollisions(function(item, other) return "cross" end)
|
||||
end
|
||||
|
||||
function Physics:move(position)
|
||||
|
@ -183,7 +186,7 @@ end
|
|||
|
||||
function Physics:_applyCollisionResponses(col)
|
||||
if (self.type == "player") and (col.other.owner ~= nil) and (col.other.owner.onPlayerCollision ~= nil) then
|
||||
col.other.owner:onPlayerCollision(self)
|
||||
col.other.owner:onPlayerCollision(self, "main", col)
|
||||
end
|
||||
self:collisionResponse(col)
|
||||
end
|
||||
|
@ -255,6 +258,9 @@ function Physics:applyHitboxCollisions(name, filter)
|
|||
|
||||
for i, col in ipairs(cols) do
|
||||
self:hitboxResponse(name, type, col)
|
||||
if (self.type == "player") and (col.other.owner ~= nil) and (col.other.owner.onPlayerCollision ~= nil) then
|
||||
col.other.owner:onPlayerCollision(self, type, col)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue