Question regarding dynamic bodies

I now have managed to move dynamic objects using a touchjoint on screen. When they collide with other dynamic bodies they change their path, like the other bodies do.

My question: Is it possible to somehow let the moving body (the one we move by using the touchjoint) just push away other dynamic bodies without changing it’s own moving path during a collision? Like a tank pushing away all other stuff without getting slowed down by the stuff? (Does this make sense?) :slight_smile:

“without changing” at all?  no, dynamic bodies are affected by collisions, both ways.  (aside: a kinematic body won’t work for you either, as by definition they don’t respond to forces, including touch joints, so it’s a non-starter)

a tank works because it’s super-massive relative to the stuff it’s brushing aside, so receives relatively little of the reaction force.  that’s the real-world model you should try to duplicate with box2d.  try just making your touch-jointed body extremely massive relative to the other bodies.  (and up the touch-joint force accordingly to compensate for “feel”)

Thank you for your quick help!

Regarding the touch-joint force: I actually just use a normal “movement” like for example I add x=x+1 and y=y+1 to the touch joint position, so it is pulling the physics object in a direction. This is not exactly a “force”.

Is there another way to still have control where to move the object exactly on screen (exact coordinates) with forces?

a touch joint works on a body by applying a force, it doesn’t matter “how” you move the touch joint’s position.

but given the way you’re using the touch joint, you could potentially eliminate it, allowing you to use a kinematic body instead (see my “aside” comment above)…

each frame simply calculate the velocity needed to reach the target position in the desired time, and set the body’s velocity directly - which you can do with a kinematic, you just can’t apply a force to produce that velocity.  kinematic acts as if infinite mass, so is unaffected by forces, including touch joints and collision response.

so,… having ditched the touch-joint requirement, that would seem to be exactly what you want:  a moving body that won’t respond to collisions.

Thanks for your detailed help!

“without changing” at all?  no, dynamic bodies are affected by collisions, both ways.  (aside: a kinematic body won’t work for you either, as by definition they don’t respond to forces, including touch joints, so it’s a non-starter)

a tank works because it’s super-massive relative to the stuff it’s brushing aside, so receives relatively little of the reaction force.  that’s the real-world model you should try to duplicate with box2d.  try just making your touch-jointed body extremely massive relative to the other bodies.  (and up the touch-joint force accordingly to compensate for “feel”)

Thank you for your quick help!

Regarding the touch-joint force: I actually just use a normal “movement” like for example I add x=x+1 and y=y+1 to the touch joint position, so it is pulling the physics object in a direction. This is not exactly a “force”.

Is there another way to still have control where to move the object exactly on screen (exact coordinates) with forces?

a touch joint works on a body by applying a force, it doesn’t matter “how” you move the touch joint’s position.

but given the way you’re using the touch joint, you could potentially eliminate it, allowing you to use a kinematic body instead (see my “aside” comment above)…

each frame simply calculate the velocity needed to reach the target position in the desired time, and set the body’s velocity directly - which you can do with a kinematic, you just can’t apply a force to produce that velocity.  kinematic acts as if infinite mass, so is unaffected by forces, including touch joints and collision response.

so,… having ditched the touch-joint requirement, that would seem to be exactly what you want:  a moving body that won’t respond to collisions.

Thanks for your detailed help!