+2 votes

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.

in Engine by (366 points)

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

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.

1 Answer

+1 vote

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

https://docs.godotengine.org/en/stable/tutorials/physics/using_area_2d.html

by (211 points)
edited by

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

Node [Area] is the equivalent in 3D.

Area and Area2D have 2 main purposes:
- Detection areas.
- Alter physical properties.

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

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 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 webmaster@godotengine.org with your username.