0
\$\begingroup\$

I need to get access project's gravity value which set in Project Settings -> Physics -> 3D -> Gravity, however I couldn't find any related information about this.

How do I get project's gravity value in GDScript? In Unity, it can be done by simply Physics.gravity, but in Godot, couldn't find similar.

Using Godot 3.1.1

\$\endgroup\$
1
\$\begingroup\$

You can access all project settings through the ProjectSettings object.

Note that the effective gravity on an object may be different from this value, as Areas can override gravity. You can access the gravity affecting an object at a given point in time via PhysicsDirectBodyState.total_gravity. PhysicsDirectBodyState can be accessed from _integrate_forces as well as some physics-related callbacks.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, it works! \$\endgroup\$
    – modernator
    Nov 1 '19 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.