How to pause gravity while object is dragged

Hi,

I modified the TimeAnimation code example by adding physics. The result is that the circle is subject to gravity even during dragging.

It is not a problem as long as the object is moved, but as soon as the dragging has no movement of its own, it is subject to gravity and drops. If I then move the object again, it returns to the position where it is dragged to.

How can I pause the effect of gravity while the object is being dragged? I cannot pause physics on the object as I need collision detection.

Hi @michel.arleth,

Assuming you’ll probably want gravity to still apply to other (not being dragged) objects, you’ll probably get better results by setting the gravity scale of the object being dragged to 0, then restoring its gravity scale afterward.

https://docs.coronalabs.com/api/type/Body/gravityScale.html

Take care,

Brent

Hi @michel.arleth,

Assuming you’ll probably want gravity to still apply to other (not being dragged) objects, you’ll probably get better results by setting the gravity scale of the object being dragged to 0, then restoring its gravity scale afterward.

https://docs.coronalabs.com/api/type/Body/gravityScale.html

Take care,

Brent