Sign in to follow this  
max lancaster

Collisions with Box2d

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.