phent_settype ( ENTITY*, var type, var hull );

Registers / unregisters an entity with the physics system. After registering, starting with the current frame the entity will be under control of the physics system (if the group bitmask is set appropriately by ph_selectgroup). After unregistering, the entity is reversed to a 'standard' Gamestudio entity and is no longer controlled by physics.


ENTITY* Entity pointer to be registered / unregistered.
type PH_RIGID to register the entity as a rigid body.
PH_WAVE  P  to register terrain as dynamic water surface.
0 for unregistering the entity from the physics system.
hull Collision hull of this object, PH_BOX, PH_SPHERE, PH_CYLINDER or PH_POLY.


1 if successful, 0 otherwise.



Slow / Medium


 A6   C   P 
 A7   P  for PH_WAVE


ENTITY* myCrate;
// ...
// on startup
myCrate = ent_create( "crate.mdl", nullvector, any_function );
phent_settype( myCrate, PH_RIGID, 0 ); 
phent_settype( myCrate, 0, 0 );
// ...
// during gameplay let's have fun with a crate:
var position;
phent_settype( myCrate, PH_RIGID, PH_BOX );
position= myCrate.x; // this will give you an approximate position
//myCrate.x = position + 10; // this won't work!
phent_settype( myCrate, 0, 0 );
myCrate.x = position + 10; // unregistered - now we can change the position
phent_settype( myCrate, PH_RIGID, PH_BOX ); // restart from new position

See also:

phent_addforceglobal, phent_addforcelocal, ph_selectgroup ► latest version online