The Raycast action casts a line from one object to another and checks to see if other objects are in the way.
This action attempts to trace a line (a “ray”) between two objects. If the ray hits some other object before reaching its target, that object and the point of intersection are stored for subsequent processing. This action allows the ray to only intersect objects with certain Tags, or to explicitly ignore intersections with objects carrying a certain tag.
A common example of ray casting in video games is a character firing a gun at a target. To see if the bullet hit the target it was aimed at, a ray is cast from the gun to the target. If something blocks the ray, the bullet can be considered to have hit that object instead, and the appropriate effects or damage calculation can be performed.
Mode
Controls whether game object regions or physics shapes should be used for ray casting.
From Object
The object at the start of the ray.
Target Object
The intended target at the end of the ray. If the ray hits this object first, the success action runs.
Require Tag
Only consider hits with this tag as valid.
Ignore Tag
Ignore objects that carry this tag.
Assign hit object to channel
Optionally assign the first hit object to a channel.
Store hit point X
An optional variable to store X coordinate of the hit point.
Store hit point Y
An optional variable to store Y coordinate of the hit point.
Action if hit target
The action to run when the ray reaches the target without another object blocking it.
Action if hit something else
The action to run when the ray is blocked by another object or misses the target.
Preview
Note that tag checking (and ignoring) only works when casting rays against game object regions. Support for collision filtering on physics shapes is forthcoming.