Very weird Box2D collision behavior

Anything libgdx related goes here!

Very weird Box2D collision behavior

Postby andy99 » Tue Aug 20, 2019 7:12 am

Hello everyone, I'm getting some very weird Box2D collision behavior. I have three types of bodies: coins, blocks, and the player.

I set coins to be sensors because they are not meant to be collided with, simply touched and then I remove the coin from the world and ecs engine. I set their collision category to be COIN_BITS (8). I set their collision mask to be PLAYER_BITS(2).

I set blocks to static. I set their collision category to be BLOCK_BITS (4). I set their collision mask to be PLAYER_BITS(2). I set the player to dynamic. I set its collision category to PLAYER_BITS(2). I set its collision mask to COIN_BITS | BLOCK_BITS (12).

My player collisions with coins is working perfectly. Unfortunately, the block collisions are VERY wacky. Almost to the point where I actually might have to dispose of the entire project. The english news capread weirdest part is that I load the coin bodies and block bodies into the world the exact same way. The only difference is that coins are kinematic bodies and the blocks are static. However, this is not the problem, as setting the blocks to kinematic does not make the system work. When my player passes over the block, most of the time it is ignored and the player passes right through. The world's contact listener does not even have its beginContact method invoked. However, some times, the player goes INSIDE the block body and gets stuck and starts vibrating. No idea where I would even start with this bug.
Last edited by andy99 on Tue Aug 27, 2019 12:38 pm, edited 1 time in total.
andy99
 
Posts: 1
Joined: Tue Aug 20, 2019 7:08 am

Re: Very weird Box2D collision behavior

Postby captainflyaway » Tue Aug 20, 2019 9:57 am

Are your bodies moving with high speed or do you not scale the bodies? Box2d cant deal with bodies that are to big.
captainflyaway
 
Posts: 237
Joined: Mon Feb 20, 2017 7:52 am


Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest