phent_addforceglobal (ENTITY* entity,VECTOR* vForce,VECTOR* vPos );

phent_addforcelocal (ENTITY* entity,VECTOR* vForce,VECTOR* vPos );

Force and torque ("angular force") will be applied to the specified entity, at global (world coordinates) or local (entity coordinates) position vPos. The force vector is independent of the objects current orientation. It is not checked whether the position is actually inside the entity, so by choosing a vPos far away from the entity, you can give it a strong spin. If vPos is exactly at the object's center of mass, no spinning will occur (consider using phent_addcentralforce in this case). phent_addforceglobal gives the same result as calling both phent_addcentralforce and phent_addtorqueglobal with the same parameters.

Parameters:

entity Entity to be affected
vForce Vector determining the force to be exerted on entity
vPos Vector specifying the point where vForce is applied

Returns:

1 if successful, 0 otherwise.

Remarks:

Speed:

Fast

Example:

ph_setgravity(vector(0,0,-386));
var mass = 10;
phent_settype( my, PH_RIGID, PH_BOX );
phent_setmass( mass );
// force is three times as strong as gravity's pull, so we can lift up the entity, while pressing a key
while (key_pressed( key_for_str("L")) )
{
  VECTOR vTemp;
  vec_set(vTemp,vector(0,0,-386)); //gravity
  vec_scale( vTemp, -3 * mass ); 
  phent_addforceglobal( myCrate, nullvector, vTemp );
  wait(1);
}

See also:

ph_selectgroup

► latest version online