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.
Start ray at a vector2 world position. Or use Game Object parameter.
A vector2 direction vector
Cast the ray in world or local space. Note if no Game Object is specified, the direction is in world space.
The length of the ray. Set to -1 for infinity.
Only include objects with a Z coordinate (depth) greater than this value. leave to none for no effect
Only include objects with a Z coordinate (depth) less than this value. leave to none
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.
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.
Pick only from these layers.
Invert the mask, so you pick from all layers except those defined above.
The color to use for the debug line.
Draw a debug line. Note: Check Gizmos in the Game View to see it in game.