bump.lua problem: Player pushed through wall

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

bump.lua problem: Player pushed through wall

Post by Gunroar:Cannon() »

I'm having problems with bump.lua...again :brows:
There's a major problem with crates pushing players through walls and I can't see a way to fix if. From what I know these functions deal with collisions in entities(crates and players)

Code: Select all

--update(number dt)
    --move(number x, number y, number dt)
    
        --resolveCollision(bump.collision collision, bool pushObjects)
        --(pushObjects is true for player but not crate)
            --changeVelocityByImpulse(bump.collision collision)
      
        --changeVelocityByCollisionNormal(number nx, number ny, number bounciness(can be blank))
but I've checked and I just can't find anything. Though crates can push crates properly.

Here's the test case:
*Click/tap on the tile to spawn something
*The first 3 taps will be a player spawned, which is just a cyan square
*The tile ontop of where the player spawned will be made solid to simulate the test environment.
*It's advisable to spawn atleast 1 player at the bottom empty tile
*The next spawns will be crates.
*The crates will push the player up/through tiles

This all happens in this game.
Attachments
Please ignore that "bouncy bullets" thing :)
Please ignore that "bouncy bullets" thing :)
Screenshot_2021-08-25-17-04-05.png (240.29 KiB) Viewed 6110 times
testcase.love
(139.13 KiB) Downloaded 101 times
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: bump.lua problem: Player pushed through wall

Post by Gunroar:Cannon() »

Hmmm, I've been experimenting and it seems removing resolveCollision for player does nothing, which is strange to me since that's where the code for pushing happens.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: bump.lua problem: Player pushed through wall

Post by Gunroar:Cannon() »

pgimeno wrote: Fri Aug 27, 2021 8:09 pm Could it have to do with this? https://love2d.org/forums/viewtopic.php?f=4&t=91440
Nope. This one isn't caused by the "bounce" collision and plus it only happens to the player.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: bump.lua problem: Player pushed through wall

Post by Gunroar:Cannon() »

Wow, this is really strange, no one has had any ideas. I thought it might have had something to do with the collision response but I don't think so now. And if I change it to touch it won't work (because touch isn't suitable, causes sticking). :?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 512
Joined: Wed Oct 05, 2016 11:53 am

Re: bump.lua problem: Player pushed through wall

Post by MrFariator »

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.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: bump.lua problem: Player pushed through wall

Post by togFox »

This is probably the wrong place and time to say this and I accept an unwelcome response, but I find the 'native' box2d physics engine supported by LOVE to be very easy to use. I scratch my head at ppl that use BUMP. The tutorials are very easy to follow. This is an unhelpful comment at the moment but suggest you consider native on your next project.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: bump.lua problem: Player pushed through wall

Post by Gunroar:Cannon() »

Thank you, Fariator! I will try that!

Edit:Oh, yes, I already make sure my things spawn out of collisions but...
MrFariator wrote: Tue Aug 31, 2021 12:07 pm
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
Image

YESS!!! It worked! Crates were rudely ignoring the player :brows: . Thanxs. :awesome:

----
togFox wrote: Tue Aug 31, 2021 12:23 pm This is probably the wrong place and time to say this and I accept an unwelcome response, but I find the 'native' box2d physics engine supported by LOVE to be very easy to use. I scratch my head at ppl that use BUMP. The tutorials are very easy to follow. This is an unhelpful comment at the moment but suggest you consider native on your next project.
Understandable, I was also once like that and I was even using box2d(windfield) when I started said project but I changed to bump.lua because of these assumptions of mine, maybe their wrong and I should go back to box2d. Prove me wrong :P !

1) It can get collisions easier: sometimes I just need objects in a certain area without them actually colliding. Box2d can do that query I believe but it seems easier in bump.

2) Perfomance? : I don't know, if I make many box2d objects (like...many) won't it cause things toneun slower or atleast take up more ram?

3) The way it's so easy to start: Just add an object to the world and no need to even keep track of the "shape". But to be fair they are both pretty easy to use.

Blgghggrh, I'm sure I had more reasons :rofl: . But I don't know, I got convinced somewhere along the line so there must be a really good reason :?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 512
Joined: Wed Oct 05, 2016 11:53 am

Re: bump.lua problem: Player pushed through wall

Post by MrFariator »

Good to know you got the thing sorted out. Those zips can be a bit annoying to track down at times.
I scratch my head at ppl that use BUMP
Bump and Box2d tackle collisions differently, and one is not superior over the other. Box2d aims to provide a realistic simulation, while bump is geared towards providing a gameistic one (see the list of bullet points on its github page). That's not to say Box2d can't do gameistic physics (eq. platformers like Shovel Knight), but the difference in design approach shouldn't go unmentioned. The choice between the two simply comes down to which one is more suited to your design goals. And of course, there's Hardon Collider as well, and even loveblobs (and probably others via luajit FFI). Never hurts having more than one or two options.
The tutorials are very easy to follow.
Sure, Box2d has more materials available due to its widespread use (not just in löve, but in other engines and frameworks in general), but Bump's tutorials are quite easy to follow too. You can learn almost all of its API by just skimming the github page, while Box2d's manual is actually quite lengthy. And if we were to go down the road that judges tools by the tutorials they provide, why use LÖVE? Unity and GameMaker have easy to follow tutorials, and in an even more ample supply than LÖVE at various skill levels, so why not use them for your next project? You can probably see how unhelpful of a suggestion that truly is.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 145 guests