How to include zero gravity in a rigid body 2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Korsut

How to include zero gravity in a rigid body 2D?

In the inspector there’s the gravity_scale property which can be set to 0, or are you after a certain behaviour using gravity?

Magso | 2020-04-25 19:01

I would like the object, being in zero gravity, to move slightly.

Korsut | 2020-04-25 19:21

In that case if you’ve got the movement you’re wanting you can set gravity_scale to 0.

If you need help with the movement have a look at these methods - translate, add_force, add_central_force and applied_force in the docs.
e.g.

add_central_force(Vector2.UP)
#This will constantly accelerate upwards.

Magso | 2020-04-25 20:20

:bust_in_silhouette: Reply From: toivocat

All you have to do is:

func _process(delta):
    gravity_scale = 0

and there that should work.