Closed sponge closed 8 years ago
Sounds like a problem with collision resolution. From what I can tell, the issue might be that you resolve collisions that are no longer happening because a previous collision was resolved. Does the issue go away if you use HC.neighbors
instead?
for shape in pairs(collider:neighbors(player)) do
local collides, dx, dy = player:collidesWith(shape)
if collides then
player:move(dx, dy)
end
end
For my example, this was the fix. It was indeed a collision response issue.
for shape in pairs(collider:neighbors(player)) do
local collides, dx2, dy2 = player:collidesWith(shape)
if collides then
player:move(dx2, dy2)
if dx2 ~= 0 then dx = 0 end
end
end
The new API is a huge improvement, but it's probably worth noting in the docs that collisions isn't just a shortcut for neighbors/collidesWith, or perhaps collisions itself should return the vector to separate from all collisions. It definitely made sense after being pointed out. Thanks!
Having a problem with collision detection of rectangles that are adjacent to each other. Not sure if's something I'm doing wrong but it seems when a shape collides with the seam of two other shapes, sometimes the moving shape will snap to the edge of one of the rectangles even though it should be falling straight down. I'll also sometimes see bouncing on falls, even though it should just be snapping right to the shape. Finally, although I'm not seeing it in my isolated example, standing on a seam seems to bounce up and down.
I've got an isolated example that seems to show most of the issues I'm having.