How do I reference the gravity variable in a script?

Hello, I was wondering if there is any one variable you can reference when writing scripts to change gravity? If there isn’t, what is a good way to go about changing gravity when a certain thing happens?

Hello @OMN1B,

You can reference the the gravity variable in a script like this:

This returns a Vec3 property. You can take a look here as well for more information: RigidBodyComponentSystem | PlayCanvas API Reference


Thank you, this helps a ton.

1 Like

You’re welcome!

If you ever wonder how to access a property you see in the PlayCanvas editor via script, you can always hover on top of it and a window with the API reference will pop up. It’s pretty useful!