The current version of Box2D in Google SVN has an example of a one-sided platform.
Detect Collision but don't resolve if relative velocity > n?
General Discussionmayobutter wrote:
I can't use sensors, because the crates should collide normally with the player in most cases. I thought about using ContactFilter->ShouldCollide to pre-detect collisions, but this is called when AABB's overlap, so my crates would blow up before a "real" contact.
I am new to Box2D, but this seems like it would work:
Inside ShouldCollide check the two shapes against each other to see if there is a "real" contact. If there is, blow up your crate. In either case, you can return false because you don't need Box2D to do anything else.
Is there any reason this wouldn't work? And is there an easy way to check two shapes against each other for intersection?
edit: After trying to implement this, I see that it won't work because ShouldCollide is only called when the shapes first get close to each other.
Original thread: https://box2d.org/forum/viewtopic.php?t=1216