Jump to content

Collisions with Box2d


max lancaster
 Share

Recommended Posts

I am using Phaser with Box2d and my system allows the user to enable/disable the properties "passthrough" and "collide with edges" for each body. "Passthrough" = pass through other bodies. "Collide with edges" = react to collisions with the walls. This setup generates 5 categories of bodies:

 

1 - walls (should collide with bodies of category 2 and 4) 
2 - "passthrough" + "collide with edges" (should collide with bodies of category 1)
3 - "passthrough" + "not collide with edges" (should collide with nothing)
4 - "not passthrough" + "collide with edges" (should collide with bodies of category 1, 4 and 5)
5 - "not passthrough" + "not collide with edges" (should collide with bodies of category 4 and 5)

 

I have set up collision filtering to meet these criteria. It works. My issue is that my system does not provide any collision information when one body passes through another. I would like to implement a function isTouching(instanceID) that allows me to determine if a body is touching another body, given their instance IDs. I have tried making these "passthrough" bodies sensors, but that makes them pass through all bodies, including walls. This doesn't work because, for example, bodies of category 2 should still collide with the walls.

 

Any tips are greatly appreciated. Thanks.

Link to comment
Share on other sites

  • 3 years later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...