Wiki

Case Status
Log In

Wiki

 
Home ยป Action Reference»Physics 2d Actions»Ray Cast 2d
Index
Navigation
Community Wiki

Ray Cast 2d

Casts a Ray against all 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. Use GetRaycastHit2dInfo to get more detailed info.

From Game Object
Start ray at game object position. Or use From Position parameter.
From Position
Start ray at a vector2 world position. Or use Game Object parameter.
Direction
A vector2 direction vector
Space
Cast the ray in world or local space. Note if no Game Object is specified, the direction is in world space.
Distance
The length of the ray. Set to -1 for infinity.
Min Depth
Only include objects with a Z coordinate (depth) greater than this value. leave to none for no effect
Max Depth
Only include objects with a Z coordinate (depth) less than this value. leave to none
Hit Event
Event to send if the ray hits an object.
Store Did Hit
Set a bool variable to true if hit something, otherwise false.
Store Hit Object
Store the game object hit in a variable.
Store Hit Point
Get the 2d position of the ray hit point and store it in a variable.
Store Hit Normal
Get the 2d normal at the hit point and store it in a variable.
Store Hit Distance
Get the distance along the ray to the hit point and store it in a variable.
Repeat Interval
Set how often to cast a ray. 0 = once, don't repeat; 1 = everyFrame; 2 = every other frame... Since raycasts can get expensive use the highest repeat interval you can get away with.
Layer Mask
Pick only from these layers.
Invert Mask
Invert the mask, so you pick from all layers except those defined above.
Debug Color
The color to use for the debug line.
Debug
Draw a debug line. Note: Check Gizmos in the Game View to see it in game.

 

Tags:

Last modified on 3/14/2016 8:37 AM by User.

  • RSS Feed