Sets the global gravity strength and direction using an acceleration vector. Often you will have gravity.x and gravity.y set to zero and gravity.z to a negative number indicating downward movement along the -Z axis. However, there are cases where you might wish to use a vector pointing in a different direction, e.g. in the +X direction for a windtunnel with wind blowing from -X to +X. The magnitude of gravity defines the acceleration imparted on all active physical entities. Earth gravity at sea level is ca -9.81 m/s2, you can set the gravity to a higher value, but be careful high values can lead to solver errors. For space simulations you can set gravity to (0,0,0) which will make the physics subsystem happy, because it has a lot less work to do. As in the real world, acceleration is independent of mass- all objects fall at the same speed no matter what their mass is.
|gravity||a 3-valued vector defining gravity direction and magnitude for all active physical entities|
1 if successful, 0 otherwise.
Note that longer timesteps lead to poor stability in the simulation, and that values beyond the abovementioned range are not recommended.
pX_setunit( 1 ); // translation 1 : 1 pXent_settype ( NULL, PH_STATIC, PH_PLANE ); ENTITY* ball = ent_create(“Ball.mdl”,nullvector, vector(0,0,50)); // position should be between -4000 and 4000 quants pXent_settype ( ball, PH_RIGID, PH_SPHERE ); pXent_setmass( ball, 2, 1 ); // Range between 1-10 pX_setgravity(vector(0,0,-9.81));