pXent_settype ( entity, var type, var hull ) |
Registers / unregisters an entity with the physics system. After registering, the entity will be under control of the physics system and a "PhysX Actor" is created (the entity group id is automatically set to 1). After unregistering, the Actor is deleted and the entity is no longer controlled by physics.
Parameters: |
entity |
Entity pointer to be registered / unregistered, or NULL for registering the level. |
type |
PH_STATIC = register the entity as a static obstacle. |
hull |
Collision hull: PH_BOX, PH_SPHERE, PH_CAPSULE, PH_POLY, PH_CONVEX, PH_TERRAIN or PH_PLANE |
Returns: |
1 if successful, 0 otherwise.
Remarks: |
This function has to be called after setting the object's position and scale, and before executing any other pXent_ functions.
Speed: |
Medium
ENTITY* myCrate; // ... // on startup myCrate = ent_create( "crate.mdl", nullvector, any_function ); pXent_settype( myCrate, PH_RIGID, PH_BOX ); pXent_settype( myCrate, 0, 0 ); // ... // during gameplay let's have fun with a crate: var position; pXent_settype( myCrate, PH_RIGID, PH_BOX ); position= myCrate.x; // this will give you an approximate position //myCrate.x = position + 10; // this won't work! pXent_settype( myCrate, 0, 0 ); myCrate.x = position + 10; // unregistered - now we can change the position pXent_settype( myCrate, PH_RIGID, PH_BOX ); // restart from new position
function f_ball() { VECTOR vKick; vKick.x = 300; vKick.y = 0; vKick.z = 100; pXent_settype(my, PH_RIGID, 1); // pXent_setmass(my, 2); pXent_setfriction(my, 100); pXent_setelasticity(my, 10); // pXent_setdamping(my, 0, 0); vec_rotate(vKick,camera.pan); pXent_addvelcentral(my, vKick); vec_set(my.blue,vector(153,247,255)); my.lightrange = 25; } function on_mouse_right_event() { while (mouse_left) {wait (1);} ENTITY* ball = ent_create ("explosion.mdl", camera.x, f_ball); set(ball,PASSABLE); }
pXent_addforceglobal, pXent_addforcelocal, pX_selectgroup, pXent_movechar