Raycaster Overview

A Raycaster is a node that can be used to check and return information on any Z.Object nodes, with a specified tag, that intersect with a ray from the Raycaster node's position down its negative Z axis.

The tag that is used to detect intersecting nodes is determined by the colliderTag property of the Raycaster node.

See also: Z.Raycaster scripting reference

Creating a Raycaster

To create a Raycaster node right click on the root node in the Hierarchy and select 'New > Raycaster' then give it a name.

Raycaster nodes are represented in the 3D view as purple arrows but won't be visible when scanning the preview or published zapcode.

A Raycaster node's visible property can be set to false in order to remove it from the 3D view, this will not affect its functionality.

Collider Tag and Limit

A Raycaster node will only return intersection events on Z.Object nodes that have the same tag as its colliderTag property.

To set the colliderTag of a Raycaster node, highlight it in the Hierarchy and click the dropdown box next to the colliderTag 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 Raycaster can then be assigned to a Z.Object node using the tags property in the Properties panel.

A Z.Object node can have multiple tags and be intersected by multiple Raycasters. A Raycaster, however, can only have one colliderTag.

The number of Z.Object nodes a Raycaster can collide with at any given time is determined by the colliderLimit property. The default value of -1 means there is no limit. Changing this to a positive value will limit the quantity of intersections to that number. This process can be seen in the video on the right.

After reaching the limit, the furthest intersections from the Raycaster will be ignored.

Next Steps

The next article discusses intersection events - the events fired as a result of a Raycaster colliding with a Z.Object node.

Next Article: Intersection Events

zapcode branded_zapcode i