If the balls you use are RigidBodies, you can use set_use_custom_integrator(). All rigid bodies have this method to turn on, or turn off, the integration of forces (like gravity) performed by Godot.
When you set set_use_custom_integrator(false)
, Godot performs integrations of forces to compute the new speed and position of the body (This is the default behavior). When you set set_use_custom_integrator(true)
, Godot doesn't integrate forces itself. That is, it ignores every forces including gravity. But you can still use the method func _integrate_forces( body_state )
to define any physic calculations yourself.
So in your case, I guess you could program your button so every bowling balls of your scene toogle their custom integrator to true or false. I suppose it won't represent much code if your button sends signals and if your bowling balls have the same script.
You may also want to immobilize your bodies once the custom integrator is used :
func _integrate_forces( body_state ):
if is_using_custom_integrator() :
body_state.set_linear_velocity( Vector2(0,0) )
body_state.set_angular_velocity( 0 )