[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

## Question regarding dynamic bodies Started by d.mach Mar 28 2019 08:54 AM

4 replies to this topic
dynamic physics bodies objects

Best Answer davebollinger , 29 March 2019 - 04:31 AM

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.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

### d.mach

[GLOBAL: userInfoPane.html]
d.mach
• Contributor

• 821 posts
• Corona SDK

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?)

[TOPIC: post.html]
#2

### davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
• Corona Geek

• 1,309 posts
• Enterprise

"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")

[TOPIC: post.html]
#3

### d.mach

[GLOBAL: userInfoPane.html]
d.mach
• Contributor

• 821 posts
• Corona SDK

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?

[TOPIC: post.html]
#4

### davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
• Corona Geek

• 1,309 posts
• Enterprise

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.

[TOPIC: post.html]
#5

### d.mach

[GLOBAL: userInfoPane.html]
d.mach
• Contributor

• 821 posts
• Corona SDK

[topic_controls]

[/topic_controls]