Apply force equal to gravity

If you’re really applying it in _process(delta), you’re probably running the game at a framerate higher than the _physics_process(delta) callback.

The correct way to apply a force to negate gravity would be:

_physics_process(delta):
	apply_central_force(-ProjectSettings.get_setting("physics/2d/default_gravity") * delta)

This ensures the force is applied only once per second, and gets the gravity from the project settings itself, automatically syncing it up.

1 Like