UnityEngine.Physics2D.Raycast C# (CSharp) Method

Raycast() public static method

Casts a ray against colliders in the scene.

public static Raycast ( Vector2 origin, Vector2 direction, [ distance, [ layerMask, [ minDepth, [ maxDepth ) : RaycastHit2D
origin Vector2 The point in 2D space where the ray originates.
direction Vector2 Vector representing the direction of the ray.
distance [ Maximum distance over which to cast the ray.
layerMask [ Filter to detect Colliders only on certain layers.
minDepth [ Only include objects with a Z coordinate (depth) greater than or equal to this value.
maxDepth [ Only include objects with a Z coordinate (depth) less than or equal to this value.
return RaycastHit2D
        public static RaycastHit2D Raycast(Vector2 origin, Vector2 direction, [DefaultValue("Mathf.Infinity")] float distance, [DefaultValue("DefaultRaycastLayers")] int layerMask, [DefaultValue("-Mathf.Infinity")] float minDepth, [DefaultValue("Mathf.Infinity")] float maxDepth)
        {
            RaycastHit2D hitd;
            Internal_Raycast(origin, direction, distance, layerMask, minDepth, maxDepth, out hitd);
            return hitd;
        }

Same methods

Physics2D::Raycast ( Vector2 origin, Vector2 direction ) : RaycastHit2D
Physics2D::Raycast ( Vector2 origin, Vector2 direction, float distance ) : RaycastHit2D
Physics2D::Raycast ( Vector2 origin, Vector2 direction, float distance, int layerMask ) : RaycastHit2D
Physics2D::Raycast ( Vector2 origin, Vector2 direction, float distance, int layerMask, float minDepth ) : RaycastHit2D
Physics2D