phent_addcentralforce ( ENTITY*, VECTOR* vForce );
A linear force is applied to the entity's center of mass during the following
frame cycle. When there is no gravity and no damping, the entity will
just
accelerate along the direction
given by vecForce,
which is independent of the body's current orientation.
Parameters:
ENTITY* |
Entity to be affected |
vForce |
Vector determining the force to be exerted on the entity at
its center of mass |
Returns:
1 if successful, 0 otherwise.
Remarks:
-
Force accelerates entities according to the Newton formula speed = time
* force / mass. Thus for higher acceleration or heavier
entities you have to use a stronger force or apply them during a
longer time.
- Avoid applying forces for a frame rate dependent time. In the worst
case - when
applying a force for one frame cycle only (time_frame) -
the entities' speed will be detemined by the frame rate.
When the engine frame rate is higher than the physics update rate
(►ph_fps_max_lock),
it can even happen that no physics update occurs in the
frame cycle and the entity is not accelerated at all.
- If you want
to accelerate the entity to a certain speed regardeless of the
frame rate, use phent_addvelcentral instead.
- Forces are additive, i.e. calling this function twice doubles the
force.
- For efficiency reasons you should prefer phent_addcentralforce to phent_addforceglobal, when possible.
Speed:
Fast
Example:
ph_setgravity( nullvector );
phent_setmass( my, 10 );
phent_setdamping (my, 0 );
// now my will continue to move along the x axis forever, with constant speed
phent_addcentralforce( my, vector(50,0,0));
See also:
► latest
version online