Ray Cast 2D
Node description and basic instructions
Last updated
Node description and basic instructions
Last updated
Casts a ray against Colliders in the Scene.
A raycast is conceptually like a laser beam that is fired from a point in space along a particular direction. Any object making contact with the beam can be detected and reported.
Raycasts are useful for determining lines of sight, targets hit by gunfire and for many other purposes in gameplay.
Additionally, this will also detect Collider(s) at the start of the ray. In this case, the ray starts inside the Collider and doesn't intersect the Collider surface. This means that the collision normal cannot be calculated, in which case the returned collision normal is set to the inverse of the ray vector being tested. This can easily be detected because such results are always at a RaycastHit2D fraction of zero.
This function returns a RaycastHit object with a reference to the Collider that is hit by the ray (the Collider property of the result will be NULL if nothing was hit).
To create it, right-click on free space in AI Tree inspector and select Create Node/Tasks/Physics2D/Ray Cast 2D.
This task node has a number of fields, that are highlighted in picture below.
Name | Description |
---|---|
Node Name | Name of node |
Ignore Abort Self | Whether node ignores abort self or not |
Origin | Origin of the Ray Cast 2D |
Direction | Direction of the Ray Cast 2D |
Max Distance | Max length of the cast (by default: infinity) |
Culling Layer | Used to selectively ignore colliders when casting a Ray Cast 2D |
Name | Description |
---|---|
Message | Value of message |
Argument | Argument of message in Blackboard |