Turning gravity on and off

Hi, I’m trying to create a game that is essentially just paper football using a 3D physics system. I want the ball to start at the bottom of the camera and then use physics to be launched through the goal post. The problem I am running into is that in order to keep the ball in front of the camera it needs to track the camera and then once the user flicks it should be launched. To make it stay in place and not fall to gravity, I am trying to turn gravity off at the start of the game and then in 1 frame, turn gravity back on and then launch the ball so that it will fly through the air as normal. This is the code I’m trying to use to do that attached to the ball entity.

Flick.prototype.update = function(dt) {
if (launch === true){
this.app.systems.rigidbody.setGravity(0,-9.8,0);
this.entity.rigidbody.applyImpulse(0, 3, -5);
console.log(“gravity on!”);
launch = false;
}
};

whenever I use this, the console tells me that setGravity is deprecated and that I should simply use gravity, but then whenever I change it, I get an error that says " this.app.systems.rigidbody.gravity is not a function." If anyone has any thoughts let me know. Another way to do this would be to turn the rigid body on and off through code but I haven’t figured out a way to do that successfully either so if you have an example of that please let me know. I tried going through different forum posts about gravity but they didn’t seem to contain this specific problem. Thanks in advance!

Try assigning new vector to gravity like this.

let value = -9.8;
this.app.systems.rigidbody.gravity = new pc.Vec3(0,value,0);