How do I set the gravity constant in an ARKit scene?

I have been messing around experimenting with some example ARKit projects (mostly this one), and have noticed that in the documentation there is no apparent reference to any method or option to change the gravity constant of the scene. In projects that use Reality Composer, there is an option for this in the Properties panel, so I assume this is feasible. How do I set my own gravity constant?


Thanks in advance!

You can change it like this:
Code Block
sceneView.scene.physicsWorld.gravity = SCNVector3(0, -0.03, 0)


According to the documentation:

The components of this vector are measured in meters per second per second. The default value is (0.0,-9.8,0.0).
This property applies a constant acceleration to all physics bodies in the world, simulating the effect of gravity near the surface of the Earth.

gravity is a SCNVector3 (kind of like an arrow in 3D space), which is formatted like (x, y, z). If you want the gravity to pull straight down, you only want to modify the y.

Zero = no gravity, and the lesser the number, the more gravity there is. Example: (0.0, -20.0, 0.0) would have much more force than (0.0, -1.0, 0.0).
As you’re currently using an example that uses RealityKit, there is no way to change the gravity value in there at present. The other answer from @ahzzheng is only relevant for SceneKit.

—————
This might change after WWDC tomorrow.
How do I set the gravity constant in an ARKit scene?
 
 
Q