Search Results for

    Show / Hide Table of Contents

    Class KaijuAgentsRaycast

    Extension methods to perform ray casting. Any Vector2 values will be expanded via the Expand(Vector2) method.

    Inheritance
    System.Object
    KaijuAgentsRaycast
    Namespace: KaijuSolutions.Agents.Extensions
    Syntax
    public static class KaijuAgentsRaycast

    Methods

    Raycast(Component, Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Component position, Component direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast.

    Component direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Component, GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Component position, GameObject direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast.

    GameObject direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast in the forward direction.

    Declaration
    public static bool Raycast(this Component position, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast which will be cast in its forward direction.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Component, Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Component position, Transform direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast.

    Transform direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Component, Vector2, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Component position, Vector2 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast.

    Vector2 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Component, Vector3, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Component position, Vector3 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Component position

    The starting position of the cast.

    Vector3 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this GameObject position, Component direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast.

    Component direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this GameObject position, GameObject direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast.

    GameObject direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast in the forward direction.

    Declaration
    public static bool Raycast(this GameObject position, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast which will be cast in its forward direction.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this GameObject position, Transform direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast.

    Transform direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, Vector2, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this GameObject position, Vector2 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast.

    Vector2 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(GameObject, Vector3, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this GameObject position, Vector3 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    GameObject position

    The starting position of the cast.

    Vector3 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Transform position, Component direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast.

    Component direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Transform position, GameObject direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast.

    GameObject direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast in the forward direction.

    Declaration
    public static bool Raycast(this Transform position, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast which will be cast in its forward direction.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Transform position, Transform direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast.

    Transform direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, Vector2, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Transform position, Vector2 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast.

    Vector2 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Transform, Vector3, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Transform position, Vector3 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Transform position

    The starting position of the cast.

    Vector3 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector2, Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector2 position, Component direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector2 position

    The starting position of the cast.

    Component direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector2, GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector2 position, GameObject direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector2 position

    The starting position of the cast.

    GameObject direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector2, Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector2 position, Transform direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector2 position

    The starting position of the cast.

    Transform direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector2, Vector2, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector2 position, Vector2 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector2 position

    The starting position of the cast.

    Vector2 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector2, Vector3, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector2 position, Vector3 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector2 position

    The starting position of the cast.

    Vector3 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector3, Component, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector3 position, Component direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector3 position

    The starting position of the cast.

    Component direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector3, GameObject, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector3 position, GameObject direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector3 position

    The starting position of the cast.

    GameObject direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector3, Transform, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector3 position, Transform direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector3 position

    The starting position of the cast.

    Transform direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector3, Vector2, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector3 position, Vector2 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector3 position

    The starting position of the cast.

    Vector2 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    Raycast(Vector3, Vector3, out RaycastHit, Single, Int32, QueryTriggerInteraction)

    Perform a raycast.

    Declaration
    public static bool Raycast(this Vector3 position, Vector3 direction, out RaycastHit hit, float distance = 3.40282347E+38F, int mask = -5, QueryTriggerInteraction triggers = null)
    Parameters
    Type Name Description
    Vector3 position

    The starting position of the cast.

    Vector3 direction

    The ending position of the cast.

    RaycastHit hit

    The hit information from the cast.

    System.Single distance

    The distance for the cast.

    System.Int32 mask

    The optional layer mask.

    QueryTriggerInteraction triggers

    How the cast should handle hitting triggers.

    Returns
    Type Description
    System.Boolean

    If the cast hit a collider or not.

    In This Article
    Back to top MIT License © 2026 Kaiju Solutions Inc.