pXcon_add ( var constraintType, ENTITY* entity1, ENTITY* entity2, var intern_collision );
Establishes a breakable joint on entity1 and entity2. The type of constraint is specified by constraintType. entity2 can be set to NULL for most constraints (excluding PH_WHEEL, which always requires 2 entities) - in this case entity1 is constrained to the world instead. Some constraints automatically set up default values, PH_HINGE and PH_BALL set the anchor point to the middle between the entities' origins.
Parameters:
constraintType |
One of the supported constraint constants PH_HINGE, PH_WHEEL, PH_BALL, PH_SLIDER,
PH_ROPE, PH_6DJOINT |
entity1 |
First entity of constraint. |
entity2 |
Second entity, chassis for a wheel, or NULL for constraining to the world. Must be different to entity1. |
intern_collision |
1 = let entity1 and entity2 collide, 0 = no internal collision |
Returns:
NxWheelShape* resp. NxJoint* pointer for further joint manipulation if successful, NULL otherwise.
Speed:
Medium
Examples:
function joints_test()
{
ENTITY* chain1 = ent_create("shell2.mdl",vector(-40,100,65),NULL);
ENTITY* chain2 = ent_create("shell2.mdl",vector(-40,100,39),NULL);
ENTITY* chain3 = ent_create("shell2.mdl",vector(-40,100,13),NULL);
set(chain1,PASSABLE);
set(chain2,PASSABLE);
set(chain3,PASSABLE);
pXent_settype(chain1,1,PH_CAPSULE);
pXent_settype(chain2,1,PH_CAPSULE);
pXent_settype(chain3,1,PH_CAPSULE);
pXcon_add ( PH_SLIDER, chain1, NULL, 0 );
pXcon_add ( PH_HINGE, chain2, chain1, 0 );
pXcon_add ( PH_BALL, chain3, chain2, 1 );
pXcon_setparams1 (chain1, vector(chain1.x,chain1.y,chain1.z+chain1.max_z), vector(0,-1,0), nullvector );
pXcon_setparams1 (chain2, vector(chain2.x,chain2.y,chain2.z+chain2.max_z), vector(-1,0,0), nullvector );
pXcon_setparams1 (chain3, vector(chain3.x,chain3.y,chain3.z+chain3.max_z), vector(0,-1,0), nullvector );
pXcon_setparams2 (chain1, vector(-1.6,1.6,50), NULL, NULL);
pXcon_setparams2 (chain2, vector(-45,45,0), NULL, NULL);
pXcon_setparams2 (chain3, vector(-45,45,0), NULL, NULL);
pXent_setsleep(chain1, 1);
pXent_setsleep(chain2, 1);
pXent_setsleep(chain3, 1);
}
See also:
Constraints, pXcon_remove, pXcon_setparams1,
pXcon_setparams2, pXcon_add