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?
Asked
Active
Viewed 160 times
0

GuilhE
- 11,591
- 16
- 75
- 116
1 Answers
1
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

Community
- 1
- 1

Kevin Workman
- 41,537
- 9
- 68
- 107
-
Hi Kevin! Thanks for your help, I was going to answer myself because I found this same solution after reading the interface ContactListener "javadoc". Yes I'm disabling the collision for a short period of time and its working. I still have a doubt. Should I put my disable logic inside beginContact() or preSolve()? – GuilhE Jun 30 '14 at 15:19
-
I could try googling some more, but the honest answer is to just try one and see if it works. And if it doesn't, try the other. – Kevin Workman Jun 30 '14 at 15:21