LibGDX - Box2D - Body interaction

I am working on a simple space shooter where I (the player) control a ship and shoot at other ships (the enemy).
I have decided to use Box2D just in case if I decide to add more features to the game.
However, I am a little confused how to do the interactions.
All of the objects in the world are bodies (obviously), even the lasers/bullets.
However, when two bodies collide, one of the bodies gives it’s momentum to the other body. How can I stop that and at the same item to use a ContactListener?
I am using DynamicBodies to be sure that I can use the ContactListener.

In fact, what is the best way to make that kind of interaction - between a bullet and a body.

You likely want to use ‘sensors’
just search for box2d sensors

You can declare a body to be a sensor, and thus it doesn’t ‘collide’ with things, but can still maintain everything else you want

Also, alternatively, you could have a ‘filter’ so that certain things don’t collide with certain other things as well. which can be useful in some circumstances.

I am not a pro by any means with box2D but one thing you should definitely do is create a class that implements the Box2DUserData. This can be set on each body and can have what ever info you want. Inside you contact listener you can filter out certain objects by group or ID or w/e and set values in your User data to indicate collisions or forces of collisions. I think the filter and sensor may be better if you do not want the bullets to apply some force to the bodies.

It took me a bit to sift through the poo tutorials on the internet to figure much out.

Thank you for your comments. I found that there is a ContactFilter which solved my problem :slight_smile: