ph_setgravity ( vecGravity );

Sets the global gravity strength and direction using an acceleration vector. Often you will have vecGravity.x and vecGravity.y set to zero and vecGravity.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 vecGravity defines the acceleration imparted on all active physical entities. Earth gravity at sea level is ca -9.81 m/s2, 1 quant is usually defined to be 1 inch, which equals 2.54 cm. Therefore to simulate gravity on earth with a standard scale you would set vecGravity.z to (-9.81 * 100 / 2.54) = -386. For space simulations you can set vecGravity 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.

Parameters:

vecGravity - a 3-valued vector defining gravity direction and magnitude for all active physical entities

Returns:

1 if successful, 0 otherwise.

Speed:

Fast

Edition:

 C   P 

Example:

var earthgravity[3] = { 0,0, -386 };
var jupiterGravity[3];
...
ph_setgravity( earthgravity );
wait(-1); // 1 second of ordinary gravity

ph_setgravity( nullvector );
wait(-1); // floating in space for another second

vec_set( jupiterGravity, earthGravity );
vec_scale( jupiterGravity, 2.5 );
ph_setgravity( jupiterGravity );
wait(-1); // things will become really heavy now..

See also:

phent_setmass ► latest version online