How is Godot gravity calculated?

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

Just curious, the gravity in the project settings seems to be set to 98 by default, what does this actually mean?

To be clear, Earth gravity is defined as 9.807 m/s², so what does that 98 mean? 98 pixels per second per second? something else?


:bust_in_silhouette: Reply From: sparkart

98 is a unit measure of 9.8m/s² represented as an integer.

:bust_in_silhouette: Reply From: kidscancode

The default value of a “unit” in 3D is a meter, so 9.8 is an approximation of real-world units.

On the other hand, in 2D, units are pixels, so it can vary widely depending on the size of your sprites. The units will be in pixels/sec^2, but 98 won’t really have much relation to reality unless you size your sprites in such a way that 10 pixels == 1 meter. In practice, especially in 2D games, a higher gravity value results in more responsive gameplay.

Thanks sparkart & kidscancode.

Knowing it is in pixel/sec^2 is useful as it gives a good baseline and takes away some of the “finger in the air” guess work.

Ratty | 2019-07-05 07:39