aside: [edit: I finally watched the clip you shared and realize you’re running in debug mode]
While I’m almost certainly wrong, my thinking is that when the player hasn’t collided yet with the ground it’s still awake because gravity is still acting on it, but after it’s collided and not moving for some time period t it goes to sleep, then you remove the ground (or set bits to 0) and physics isn’t being simulated for the player because it’s asleep:
- Player is above ground and falling
- Player contacts ground and stops moving
- Player physics object goes to sleep
- Ground bit mask is reset to not apply to player collisions (expecting player to now fall through)
- Player doesn’t move because it’s asleep and physics (even gravity) is not applying to it
You could at least debug or print out the body’s various state, such as
bool awake or 'bool allowSleep`.
Not sure whether you need to investigate @panor’s reply about (continuous collision detection (CCD), or something else like setting a category filter?
maybe check iforce2d’s docs (though coco2d may default to Chipmunk?):
- Anatomy of a collision - Box2D tutorials - iforce2d
- Collision callbacks - Box2D tutorials - iforce2d
- Collision filtering - Box2D tutorials - iforce2d
again, I don’t often use 2d physics (only in unity games) so I’m not well versed in the Box2d or Chipmunk (both are supported in Cocos2D, but I don’t know the default as I write non-physics-based collisions and gravity when needed, which hasn’t been often for the games I’ve worked on).