As far as I can tell, this seems like typical "zipping" (a term used when describing odd behavior, where the game actively tries to push an object,
such as player, out of a wall). You usually see this behavior with bump when an object finds itself overlapping something it's supposed to collide with according to the provided filter, and it returns the "slide" response.
For example, this scenario:
1. Object X is updated, and moves inside Object Y
2. Object X is not set to collide with Object Y according to its filter, so nothing happens
3. Later in the frame, Object Y is updated
4. Object Y returns 'slide' from the collision with Object X, as specified in its filter
5. As a result, Object Y may get 'zipped'
somewhere next to Object X
As such, when "slide" collision response is used, you have one simple rule: don't ever let two objects that collide overlap, or one of them is bound to get zipped who-knows-where. As far as I can tell, the zipping behavior is consistent, but hard to predict, particularly when the number of collidables increases.
Usually to avoid such situations, upon spawning an object that might get zipped, I check for the presence of a collidable where the object is going to spawn (using queryRect or so), and then either make the object ignore the collision. Something like:
Code: Select all
-- upon spawning an object, check for collidables
-- for every hit, put them into a table
local hits, len = bumpWorld:queryRect(x,y,w,h,filter) -- adjust filter function based on what objects you're not supposed to collide with
if len > 0 then
self.ignoredColliders = {}
for i = 1, len do
self.ignoredColliders = hits[i]
end
end
-- and then the filter we use when moving the object is something like
function ( item, other )
if item.ignoredColliders and item.ignoredColliders[other] then
return -- because we return nothing, we ignore the collision entirely
end
-- rest of the filter function
end
At some point you then check that the spawned object has exited the other collider, and empty the 'ignoredColliders' table accordingly.
And then in other cases, for some other types of objects (eq. projectiles, breakables, enemies), I instead simply immediately destruct the object if it finds itself spawning inside a collidable.
This is just one of those areas where bump can be a bit finnicky to use, and can create great many little headaches.