I have created platform using box2d. I want box2d body detect and not detect dynamically.
Box2d shapes will do the followings
- Detect collision on some condition
- Not detect collision on some condition
Both condition will work on different condition in same box2d object.
Any idea would help a lot. Thanks in advance.
There are several ways to control what happens when a collision occurs in Box2d. The first thing to do is read this article and decide on what way you want to control it.
That gives you several options. Here is what I did for the last game I worked on where this mattered:
To determine "when the collision occurs", use contact filtering:
Use the class above as a base class for your own contact class and override the ShouldCollide(...) method with something like this:
When you create the body, call
on each fixture attached to the bodies you want to "filter". The filter must "exist" somewhere other than on the stack (maybe as a static member in your Controller itself, so you can customize it).
Was this helpful?