+2 votes

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.

in Engine by (139 points)

1 Answer

+4 votes
Best answer

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")
by (1,656 points)
selected by

Thanks, it works!

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.