TriggerRegion Overview
A TriggerRegion is a node that can be used to determine if the origin point of specified Z.Object nodes are within a defined area.
See also: Z.TriggerRegion scripting reference
Creating a TriggerRegion
To create a TriggerRegion node right click on the root node (or a group node) in the Hierarchy and select 'New > TriggerRegion' then give it a name.
TriggerRegions are represented in the 3D view as wireframes but won't be visible when scanning the preview or published zapcode.
When previewing in the desktop version of the Zappar app TriggerRegions are visible to help with debugging.
TriggerRegion triggerTag
A TriggerRegion node will only emit events for Z.Object nodes that have the same tag
as its triggerTag
property.
To set the triggerTag
of a TriggerRegion node, highlight it in the Hierarchy and click the drop-down box next to the triggerTag
property within the Properties panel. Any existing tags will be listed as well as the option to create a new one.
A tag assigned to a triggerRegion
can then be assigned to Z.Object nodes using the tags
property in the Properties panel.
TriggerRegion Shape
The default shape
for TriggerRegions is a cube.
The shape of a TriggerRegion can be changed by clicking on the drop-down next to the shape
property within the Properties panel.
As TriggerRegions define a 3D area, it's best to place them somewhere in the Hierarchy where this is observable.
TriggerRegion localPosition and parentPosition
The events that are emitted by TriggerRegions can report object positions in either the TriggerRegion's local coordinate system or that of the TriggerRegion's parent. The object positions are accessed through TriggerPresentEvents, an argument passed in TriggerRegion event handler functions.
Whether the positions should be passed or not is determined by the reportLocalPosition
and reportParentPosition
properties of the TriggerRegion which can be set from the relevant checkboxes in the Properties panel.
By default reportLocalPosition
is set to true and reportParentPosition
is set to false.
- localPosition: A value between
[-1,-1,-1]
and[1,1,1]
depending on the location of the object within the TriggerRegion; regardless of the scale, rotation and position of the TriggerRegion or any of its parents. - parentPosition: A value affected by the scale, rotation and position of the TriggerRegion. E.g. With a TriggerRegion of scale
[2,2,2]
the parentPosition equivalent of an object reporting a localPosition of[0.5,0.5,0.5]
would be[1,1,1]
.
Next Steps
The next article discusses TriggerRegion events - the events fired as a result of a Z.Object node interacting with the area defined by a TriggerRegion.