Search code examples
cocos2d-xchipmunkcocos2d-x-3.0

Detect intersection without causing bodies to collide


I want to detect the intersection of two objects (sprites) in my scene. I don't want the object geometric intersection to cause a collision between the bodies in the scene.

I've created PhysicalBody for both of my object shapes, but I can't find a way to detect the intersection without having both bodies hit each other on impact.

I'm using cocos2d-x 3+ with the default chipmunk engine (which I'd like to stick with for now)

The question is, how do I detect the intersection of elements without having them physically push each other when they intersect.


Solution

  • The answer is very simple (Though it took me 2 days to figure it out)

    When contact is detected and onContactBegin() is called, when the relevant shape is being hit returning false will stop the physical interaction.