phcon_add ( var constraintType, ENTITY* entity1, ENTITY* entity2 );

Establishes a new constraint on entity1 and entity2. The type of constraint is specified by constraintType. When successful, a constraint_id is returned which has to be used in subsequent phcon_ calls. entity2 can be set to 0 for most constraints (excluding PH_WHEEL, which 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 lie in the middle between the entities' origins.

Parameters:

constraintType one of the supported constraint constants PH_HINGE, PH_WHEEL, PH_BALL, PH_SLIDER
entity1 first entity of constraint
entity2 second entity of constraint or NULL when not required

Returns:

constraint_id - unique identifier of this constraint. Store this ID for removing constraint or altering its properties.

Speed:

Medium

Example:

var hingeID;
var axis[3]= 1,0,0; // pendulum is allowed to rotate only along the x-axis
var anchor[3];
vec_set( anchor, blade_entity.x );
anchor.z = ceiling_height; // anchor point is now above blade at the specified height

// this sets up a hinged pendulum, suspended from the ceiling 
hingeID= phcon_add( PH_HINGE, blade_entity,NULL);
phcon_setparams1(hingeID,anchor,axis,NULL);

See also:

constraints, phcon_remove, phcon_setparams1, phcon_setparams2

► latest version online