GuilhE
GuilhE

Reputation: 11861

Box2D DynamicBody collision with KinematicBody

I've a Dynamic Body that collides with Kinematic Bodies being thrown at it.
In a particular situation (a different kind of Kinematic Body lets say) I still want the collision detection by the ContactListener but without affecting the Dynamic Body with the collision resultant forces.
Is is possible? If so how can I achieve that?

Upvotes: 0

Views: 263

Answers (1)

Kevin Workman
Kevin Workman

Reputation: 42176

This is stretching my memory a bit, and you haven't posted an MCVE that we can play with, but I believe you can use a contact callback and the beginContact() or preSolve() methods to "cancel" the collision.

Sources: http://www.iforce2d.net/b2dtut/collision-anatomy https://gamedev.stackexchange.com/questions/15985/how-can-i-cancel-a-contact-in-a-b2contactlistener

You might also consider using a sensor instead of a body, depending on what you're trying to do.

Edit: Some more sources seem to confirm, maybe my memory isn't as bad as I thought! Set contact enabled in box2d andengine

How to detect collision but do not collide in box2d?

Upvotes: 1

Related Questions