+2 votes


I curious how to make planet to be as gravity point that attracts moon (or other object). I think that I need to use Area node (but not sure). Please can someone point me to the right direction? (I guess 2D or 3D works in similar way)

Thank you

in Engine by (111 points)

1 Answer

+3 votes
Best answer

Area space override gives you options to add, replace and combine many properties like gravity (even use negative gravity to expel, simulate water and add damp for density/simulate 3D surfaces on 2D).

Do some tests, make an area with space override and put a body in direction of that area to see how works.

But is hard to control this, also while debugging, the physics may work a bit wrong and the effect could be different on release, so may be better to simulate orbits in a complete fake way instead of letting the physics engine to do it, let the engine work alone where you don't care of the results.

Still, you can use Area information for your calculations, on process or with a custom integrator (rigid) to control and force objects to keep an orbit.

Here is an example of something that only happened to me while debugging (there is an area with gravity replace and point, centered on the planet, the rest are rigids):

Here is a small word in 3D, "bullets" are rigids affected by Area gravity point:

by (7,934 points)
selected by

Thank you eons for answer I trying to test as you said but no luck at all. please maybe you can explain in detail how to set up scene? for now I have area node (test cube is a child) and another node is rigid body and what I trying to do simply rigid body falls near area and if I understand correctly area should pull rigid body?

To make things easier at first, put the general gravity on 0 at project settings so you don't have to deal with replace and combine options because are a bit confusing.

Turn on collision shape visibility on the editor debug options (to make things faster).

  • Make a root like always (Node, Spatial, anything).
  • Add an Area with any shape (better box or sphere to have an idea of what is happening), make it big. Put space override on combine or replace and check gravity point (to make a central gravity).
  • Add a RigidBody far from the area center but inside the area (not a child, in shape), add a shape so you see it.
  • Add more rigid bodies inside and outside the area shape.
  • And of course, a camera to see the scene.
  • If you turn on sync scene changes, you can play with area gravity values on the editor and watch the effects on the running scene.

Then you can make it more pretty with meshes, some static or kinematic bodies on the area center, that way it will look like if the rigids are attracted by an object.

thank you for your time but still nothing... do not understand or I doing something wrong or what happening :D
here is an image what I done (and if you will see what I dong wrong please tell me):
my scene

If the central one is the area, make it bigger so it affects the bodies (need to touch them).

Deformed shapes may not work well, btw, try to do uniform scales (same x and y) or use a polygon.

Some bodies ignore scales too, is better to change shape's size instead.

I stuck and not sure why nothing happening.. I will look for some examples on the internet.

Thank you eons

Save this as a tscn file

You may need more practice with the basics before suffering the physics engine ^^;

ohh I see now what I did wrong I made area it self big not and collision shape wasn't . just one simple question if I change rigid body mode to kinematic area not attracting, this works just with rigid bodies?
Thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.