kikito / bump.lua

A collision detection library for Lua
MIT License
939 stars 86 forks source link

Check never returns multiple collisions. #52

Closed lucassardois closed 5 years ago

lucassardois commented 5 years ago

Hello,

It seems that the check function never returns multiples collisions when they occurs. It always only return the first one.

function Clone:move(vx, vy)
  local xx = self.x + vx
  local yy = self.y + vy
  local nx, ny, cols, len = self.world:check(self, xx, yy)

  if self:isGoingUp(vy) then
    for i = 1, len do
      local col = cols[i]
      local other = col.other
      if col.normal.x == 0 and other.isClone then
        other:move(0, vy)
      end
    end

   -- Make the player "stick" to the entity it just pushed
   ...
  end

  self.x, self.y = x, y
  self.world:update(self, x, y)
end
lucassardois commented 5 years ago

More news : I found out that calling check or project return differents results for the number of collisions for the same parameters.

_, _, cols1, len1 = self.world:check(self, goalX, goalY)
cols2, len2 = self.world:project(self, self.x, self.y, self.w, self.h, goalX, goalY)

Here len1 ~= len2