How to get global gravity from gdscript?

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

I want to get gravity value which was set in Project Settings > Physics → 3D. I tried to find this almost an half hour but nothing related found.

How do I get gravity vector from GDScript? In Unity, it’s simply just: Physics.gravity.

:bust_in_silhouette: Reply From: Eric Ellingson

If you hover over the name of the setting in the project settings window, it will tell you the string/path needed to retrieve that value.

var gravity_vector : Vector2 = ProjectSettings.get_setting("physics/2d/default_gravity_vector")
	var gravity_magnitude : int = ProjectSettings.get_setting("physics/2d/default_gravity")

Thanks, it works!

rico345100 | 2019-11-01 14:24