4.3.12 Trigger

The trigger property class is capable of detecting when another entity (that has a pcmesh) enters or leaves an area defined by this trigger. In that case it can send messages to the entity that contains this property class and/or the entities that enter/leave the trigger area.

Property Class Details

Name:
‘pclogic.trigger’

Factory ID:
‘cel.pcfactory.logic.trigger’

Interface:
iPcTrigger

Header:
‘include/propclass/trigger.h’

General Information

PcTrigger can be used when you want an entity to receive messages when some other entity enters or leaves a certain area of influence. Also the entity entering the trigger will receive a message on entering or leaving the area.

Currently it has support for different area types, including Sphere, Box, Beam and AboveMesh.

Sphere: This is defined by a sphere with a certain radius and a certain position and sector.

Box: Similar to the sphere trigger but with a box area of influence defined by minimum and maximum corners and a sector.

Beam: A beam trigger defined by a sector and start and end vectors. Will be triggered when something enters this vector.

AboveMesh: AboveMesh trigger works by finding out when another entity is over the entity targeted by this property class. It is defined by an entity to detect from, and a maximum distance to check over it.

SetupTrigger<TriggerType> method is available as api function and action to setup the trigger either at runtime code or in map/quest xml.

Also further functionality is available from iPcTrigger api to set callbacks or some additional customization (check api docs).

Trigger Message Callbacks

The following messages are sent by this property class:

pctrigger_entityenters: an entity enters this trigger.

pctrigger_entityleaves: an entity leaves this trigger.

pctrigger_entertrigger: this entity enters a trigger.

pctrigger_leavetrigger: this entity leaves a trigger.

All messages receive an ‘entity’ parameter with the entity with the trigger (for _leavetrigger and _entertrigger messages), or the entity entering the trigger (for _entityenters or _entityleaves messages).

Trigger Properties

This property class has some properties to further customize trigger behaviour.