Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:3.6

Description

Description:

Defines a trigger area, using a sequence of points.

The points describe the path for the area outline. Their order is crucial.

The image below shows several paths, and the order in which they are passed to the command. The polygon is automatically closed by connecting the last point with the first one (for instance, point 6 is the last one defined, so the engine connects it with point 1).

If the sequence is changed (even though the locations of the points themselves are the same), the result is different:

The points can be defined either as absolute coordinates (the map position), or relative to the triggers location. For absolute coordinates, the trigger position is moved to the center of the polygon; for relative coordinates, then the trigger position stays the same (if the trigger is rotated already, then that angle is ignored when calculating the relative position). Once the trigger is defined (with either method), it can be moved using setPos, and it keeps its shape. Polygons cannot be rotated manually, but if they are attached to an object, they rotate to keep their original alignment with the parent object.

Be aware that the representation of polygon triggers in the editor is not accurate: it is normally a rectangle that represents the maximum dimensions of the polygon, but it never actually displays the polygon itself. To display a polygon on the map, see drawPolygon.

Syntax

Syntax:trigger setTriggerAreaPolygonal [points, absolute]
Parameters:
  • trigger: Object - Trigger object.
  • points: Array of Position-2 - Polygon definition (see description). Must be at lease 3 points, otherwise the command is not executed.
  • absolute: Boolean - If true, then the points define the absolute map positions; if false, then they are relative to the current position of the trigger.
Return Value:Nothing

Examples

Examples:
Create a triangular trigger zone, using absolute coordinates:
trg1 setTriggerAreaPolygonal [[[2400,2500],[2500,2600],[2600,2500]], true];

Create a triangular trigger zone, using relative coordinates:
trg2 setTriggerAreaPolygonal [[[-2,0],[0,2],[2,0]], false];

Create a complex trigger zone, using existing markers: // read all existing markers ("m1" to "m14"), and store their positions in an array _positions = []; for "_i" from 1 to 14 do { _positions = _positions + [getMarkerPos format["m%1",_i]]; }; // create a trigger (initial position does not matter) trg1=createTrigger["EmptyDetector",[1,1]]; // define the area, using the stored positions trg1 setTriggerAreaPolygonal [_positions,true];

The green markers (1-14) indicate the polygon points used, and the red markers (created in a different script) indicate the covered area (see Polygon_Triggers.zip).

Additional Information

See also: triggerAreaPolygonal, setTriggerArea
Multiplayer:
Problems:

Notes