How to get Area2D gravity point working?

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

Hi,

I’m experimenting with a game and I’d like to create different points of gravity on the map that physics bodies are pulled towards.

Looking at Area2D is has a setting for gravity point…but no matter what settings I apply, the bodies are never “pulled” towards the point. I do have the global gravity set to 0,0 because I don’t want the bodies falling down, but it doesn’t work with “normal” (0, 1) gravity either.

Anyone have any experience with gravity points and managed to get it working? Thanks!

Using Godot 3.1 BETA 10.

mmmm. Maybe it is a bug? it seems not to work to me either…
Report the issue to Godot repository on Github, they might help you find out if this is a regular behaviour or not

salvob | 2019-03-11 14:07

Late reply but I set the Space Override property (directly above Gravity Point in the inspector) from ‘Disabled’ (default) to ‘Replace’. I think it was using point gravity as well as default gravity, which is probably the issue you were having too.

EmeraldSlash | 2019-05-15 22:17

:bust_in_silhouette: Reply From: luislodosm

To make an attractor, such as a planet or black hole for a space game, set the following parameters:

[Area2D] (with Collision Shape, of course)
Space Override = Combine
Gravity Point = Enabled

[Proyect settings]
Default Gravity = 0

[RigidBody2D] (all bodies that you want to be affected)
Gravity Scale = 1

Is there a 3D version of this node that can effect gravity in this way?

Millard | 2020-05-23 01:53

Node [Area] is the equivalent in 3D.

Area and Area2D have 2 main purposes:

  • Detection areas.
  • Alter physical properties.

luislodosm | 2020-05-23 07:18

Thanks, I’m a beginner and that will be a nice node to put under my belt. :slight_smile:

Millard | 2020-05-24 23:12