+1 vote

Greetings!

How can I change the gravity of my entire scene programatically?

I saw that I can use the PhysicsServer to achieve this. However, when I change the gravity vector, the gravity stops working altogether.

This is the code I am using:

PhysicsServer.area_set_param(get_world().get_space(), 
    PhysicsServer.AREA_PARAM_GRAVITY_VECTOR, gravity_dir)
PhysicsServer.area_set_param(get_world().get_space(), 
    PhysicsServer.AREA_PARAM_GRAVITY, 9.8)
asked Apr 10 in Engine by Juxxec (62 points)

1 Answer

+1 vote

There is a bug open about this: https://github.com/godotengine/godot/issues/35378

It works if you change the physics engine to GodotPhysics in your project settings.

Another alternative which doesn't involve changing the physics engine is to turn off gravity, and apply its force yourself.

answered Apr 10 by Zylann (26,033 points)
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 How to use this Q&A? before posting your first questions.