Search Results for

    Show / Hide Table of Contents

    Class KaijuAgentsSphereCast

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

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

    Methods

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Component position, Component direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Component position, GameObject direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a SphereCast in the forward direction.

    Declaration
    public static bool SphereCast(this Component position, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Component position, Transform direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Component position, Vector2 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Component position, Vector3 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this GameObject position, Component direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this GameObject position, GameObject direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a SphereCast in the forward direction.

    Declaration
    public static bool SphereCast(this GameObject position, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this GameObject position, Transform direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this GameObject position, Vector2 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this GameObject position, Vector3 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Transform position, Component direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Transform position, GameObject direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a SphereCast in the forward direction.

    Declaration
    public static bool SphereCast(this Transform position, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Transform position, Transform direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Transform position, Vector2 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Transform position, Vector3 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector2 position, Component direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector2 position, GameObject direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector2 position, Transform direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector2 position, Vector2 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector2 position, Vector3 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector3 position, Component direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector3 position, GameObject direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector3 position, Transform direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector3 position, Vector2 direction, float radius, 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.

    System.Single radius

    The radius 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.

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

    Perform a sphere cast.

    Declaration
    public static bool SphereCast(this Vector3 position, Vector3 direction, float radius, 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.

    System.Single radius

    The radius 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.