pXent_settriggerflag
(ENTITY* entity, var type, var trigger)
This
function uses the volume of a
static
actor as a trigger area that generates an ENABLE_TRIGGER event.
Parameters:
entity |
Registered PH_STATIC entity. |
type
|
NX_TRIGGER_ON_ENTER
NX_TRIGGER_ON_LEAVE
NX_TRIGGER_ON_STAY
NX_TRIGGER_ENABLE (sets all 3 flags together) |
trigger |
1 = on, 0 = off |
Returns:
Trigger area number if successful, 0
otherwise.
Remarks:
- This function also sets the
entity's ENABLE_TRIGGER flag.
- In the
event function, the me/my pointer is the trigger area entity, the you pointer is
the actor that collides with the trigger.
- The actor->userdata struct gets overwritten (internally), but
this normally won't cause problems.
Do not set this flag for
dynamic actors.
Speed:
Fast
Example:
function EventTrigger()
{
reset(my,TRANSLUCENT); //to visualize the collision
pX_setforcemode(NX_FORCE);
pXent_addexplosion(you,my.x,500,my.max_x/2); // you is the entity that collides with the trigger object
wait(-1);
set(my,TRANSLUCENT);
}
...
ENTITY* trigger_zone = ent_create("earth.mdl",vector(0,0,0),NULL);
pXent_settype(trigger_zone,PH_STATIC,PH_SPHERE);
pXent_settriggerflag(trigger_zone, NX_TRIGGER_ON_ENTER, 1);
trigger_zone.event = EventTrigger;
See also:
pX_setforcemode,
pXent_addexplosion,
pXent_settype