docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ICollidable

    Interface for objects that can be hit by physics queries.

    Namespace: Unity.Physics
    Assembly: Unity.Physics.dll
    Syntax
    public interface ICollidable

    Methods

    BoxCast(float3, quaternion, float3, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)

    Casts a specified box along a ray specified with center, direction, and maxDistance, and checks if it hits an ICollidable. Return true if a hit happened, the information about closest hit will be in hitInfo.

    Declaration
    bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    ColliderCastHit hitInfo

    [out] Information describing the hit.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    BoxCast(float3, quaternion, float3, float3, float, CollisionFilter, QueryInteraction)

    Casts a specified box along a ray specified with center, direction, and maxDistance, and checks if it hits an ICollidable. Return true if there is at least one hit.

    Declaration
    bool BoxCast(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    BoxCastAll(float3, quaternion, float3, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)

    Casts a specified box along a ray specified with center, direction, and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, all hits will be stored in a provided list.

    Declaration
    bool BoxCastAll(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    NativeList<ColliderCastHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    BoxCastCustom<T>(float3, quaternion, float3, float3, float, ref T, CollisionFilter, QueryInteraction)

    Casts a specified box along a ray specified with center, direction, and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, the passed collector is used for custom hit filtering.

    Declaration
    bool BoxCastCustom<T>(float3 center, quaternion orientation, float3 halfExtents, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CalculateAabb()

    Calculate an axis aligned bounding box around the object, in local space.

    Declaration
    Aabb CalculateAabb()
    Returns
    Type Description
    Aabb

    The calculated aabb.

    CalculateDistance(ColliderDistanceInput)

    Calculate the distance from a collider to the object. Return true if there are any hits.

    Declaration
    bool CalculateDistance(ColliderDistanceInput input)
    Parameters
    Type Name Description
    ColliderDistanceInput input

    The input.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance(ColliderDistanceInput, ref NativeList<DistanceHit>)

    Calculate the distance from a collider to the object. Return true if there are any hits, with details of every hit in "allHits".

    Declaration
    bool CalculateDistance(ColliderDistanceInput input, ref NativeList<DistanceHit> allHits)
    Parameters
    Type Name Description
    ColliderDistanceInput input

    The input.

    NativeList<DistanceHit> allHits

    [in,out] all hits.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance(ColliderDistanceInput, out DistanceHit)

    Calculate the distance from a collider to the object. Return true if there are any hits, with details of the closest hit in "closestHit".

    Declaration
    bool CalculateDistance(ColliderDistanceInput input, out DistanceHit closestHit)
    Parameters
    Type Name Description
    ColliderDistanceInput input

    The input.

    DistanceHit closestHit

    [out] The closest hit.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance(PointDistanceInput)

    Calculate the distance from a point to the object. Return true if there are any hits.

    Declaration
    bool CalculateDistance(PointDistanceInput input)
    Parameters
    Type Name Description
    PointDistanceInput input

    The input.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance(PointDistanceInput, ref NativeList<DistanceHit>)

    Calculate the distance from a point to the object. Return true if there are any hits, with details of every hit in "allHits".

    Declaration
    bool CalculateDistance(PointDistanceInput input, ref NativeList<DistanceHit> allHits)
    Parameters
    Type Name Description
    PointDistanceInput input

    The input.

    NativeList<DistanceHit> allHits

    [in,out] all hits.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance(PointDistanceInput, out DistanceHit)

    Calculate the distance from a point to the object. Return true if there are any hits, with details of the closest hit in "closestHit".

    Declaration
    bool CalculateDistance(PointDistanceInput input, out DistanceHit closestHit)
    Parameters
    Type Name Description
    PointDistanceInput input

    The input.

    DistanceHit closestHit

    [out] The closest hit.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CalculateDistance<T>(ColliderDistanceInput, ref T)

    Calculate the distance from a collider to the object. Return true if there are any hits, with details stored in the collector implementation.

    Declaration
    bool CalculateDistance<T>(ColliderDistanceInput input, ref T collector) where T : struct, ICollector<DistanceHit>
    Parameters
    Type Name Description
    ColliderDistanceInput input

    The input.

    T collector

    [in,out] The collector.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CalculateDistance<T>(PointDistanceInput, ref T)

    Calculate the distance from a point to the object. Return true if there are any hits, with details stored in the collector implementation.

    Declaration
    bool CalculateDistance<T>(PointDistanceInput input, ref T collector) where T : struct, ICollector<DistanceHit>
    Parameters
    Type Name Description
    PointDistanceInput input

    The input.

    T collector

    [in,out] The collector.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CapsuleCast(float3, float3, float, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)

    Casts a capsule specified with two points along a ray specified with the center of the capsule, direction and maxDistance, and checks if it hits an ICollidable. Return true if a hit happened, the information about closest hit will be in hitInfo.

    Declaration
    bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    ColliderCastHit hitInfo

    [out] Information describing the hit.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CapsuleCast(float3, float3, float, float3, float, CollisionFilter, QueryInteraction)

    Casts a capsule specified with two points along a ray specified with the center of the capsule, direction and maxDistance, and checks if it hits an ICollidable. Return true if there is at least one hit.

    Declaration
    bool CapsuleCast(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CapsuleCastAll(float3, float3, float, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)

    Casts a capsule specified with two points along a ray specified with the center of the capsule, direction and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, all hits will be stored in a provided list.

    Declaration
    bool CapsuleCastAll(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    NativeList<ColliderCastHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CapsuleCastCustom<T>(float3, float3, float, float3, float, ref T, CollisionFilter, QueryInteraction)

    Casts a capsule specified with two points along a ray specified with the center of the capsule, direction and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, the passed collector is used for custom hit filtering.

    Declaration
    bool CapsuleCastCustom<T>(float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CastCollider(ColliderCastInput)

    Cast a collider against the object. Return true if it hits.

    Declaration
    bool CastCollider(ColliderCastInput input)
    Parameters
    Type Name Description
    ColliderCastInput input

    The input.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CastCollider(ColliderCastInput, ref NativeList<ColliderCastHit>)

    Cast a collider against the object. Return true if it hits, with details of every hit in "allHits".

    Declaration
    bool CastCollider(ColliderCastInput input, ref NativeList<ColliderCastHit> allHits)
    Parameters
    Type Name Description
    ColliderCastInput input

    The input.

    NativeList<ColliderCastHit> allHits

    [in,out] all hits.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CastCollider(ColliderCastInput, out ColliderCastHit)

    Cast a collider against the object. Return true if it hits, with details of the closest hit in "closestHit".

    Declaration
    bool CastCollider(ColliderCastInput input, out ColliderCastHit closestHit)
    Parameters
    Type Name Description
    ColliderCastInput input

    The input.

    ColliderCastHit closestHit

    [out] The closest hit.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CastCollider<T>(ColliderCastInput, ref T)

    Generic collider cast. Return true if it hits, with details stored in the collector implementation.

    Declaration
    bool CastCollider<T>(ColliderCastInput input, ref T collector) where T : struct, ICollector<ColliderCastHit>
    Parameters
    Type Name Description
    ColliderCastInput input

    The input.

    T collector

    [in,out] The collector.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CastRay(RaycastInput)

    Cast a ray against the object.

    Declaration
    bool CastRay(RaycastInput input)
    Parameters
    Type Name Description
    RaycastInput input

    The input.

    Returns
    Type Description
    bool

    True if it hits, otherwise false.

    CastRay(RaycastInput, ref NativeList<RaycastHit>)

    Cast a ray against the object. Return true if it hits, with details of every hit in "allHits".

    Declaration
    bool CastRay(RaycastInput input, ref NativeList<RaycastHit> allHits)
    Parameters
    Type Name Description
    RaycastInput input

    The input.

    NativeList<RaycastHit> allHits

    [in,out] all hits.

    Returns
    Type Description
    bool

    Return true if it hits, with details of the closest hit in "closestHit".

    CastRay(RaycastInput, out RaycastHit)

    Cast a ray against the object.

    Declaration
    bool CastRay(RaycastInput input, out RaycastHit closestHit)
    Parameters
    Type Name Description
    RaycastInput input

    The input.

    RaycastHit closestHit

    [out] The closest hit.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CastRay<T>(RaycastInput, ref T)

    Generic ray cast. Return true if it hits, with details stored in the collector implementation.

    Declaration
    bool CastRay<T>(RaycastInput input, ref T collector) where T : struct, ICollector<RaycastHit>
    Parameters
    Type Name Description
    RaycastInput input

    The input.

    T collector

    [in,out] The collector.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    CheckBox(float3, quaternion, float3, CollisionFilter, QueryInteraction)

    Checks if the provided box is overlapping with an ICollidable Return true if it is overlapping.

    Declaration
    bool CheckBox(float3 center, quaternion orientation, float3 halfExtents, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CheckCapsule(float3, float3, float, CollisionFilter, QueryInteraction)

    Checks if the provided capsule is overlapping with an ICollidable Return true if it is overlapping.

    Declaration
    bool CheckCapsule(float3 point1, float3 point2, float radius, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    CheckSphere(float3, float, CollisionFilter, QueryInteraction)

    Checks if the provided sphere is overlapping with an ICollidable Return true if it is overlapping.

    Declaration
    bool CheckSphere(float3 position, float radius, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 position

    The position.

    float radius

    The radius.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    OverlapBox(float3, quaternion, float3, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)

    Checks if the provided box is overlapping with an ICollidable Return true if there is at least one overlap, and all overlaps will be stored in provided list.

    Declaration
    bool OverlapBox(float3 center, quaternion orientation, float3 halfExtents, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    NativeList<DistanceHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    OverlapBoxCustom<T>(float3, quaternion, float3, ref T, CollisionFilter, QueryInteraction)

    Checks if the provided box is overlapping with an ICollidable Return true if there is at least one overlap, the passed collector is used for custom hit filtering if needed.

    Declaration
    bool OverlapBoxCustom<T>(float3 center, quaternion orientation, float3 halfExtents, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
    Parameters
    Type Name Description
    float3 center

    The center.

    quaternion orientation

    The orientation.

    float3 halfExtents

    Half extents of the box.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    OverlapCapsule(float3, float3, float, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)

    Checks if the provided capsule is overlapping with an ICollidable Return true if there is at least one overlap, and all overlaps will be stored in provided list.

    Declaration
    bool OverlapCapsule(float3 point1, float3 point2, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    NativeList<DistanceHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    OverlapCapsuleCustom<T>(float3, float3, float, ref T, CollisionFilter, QueryInteraction)

    Checks if the provided capsule is overlapping with an ICollidable Return true if there is at least one overlap, the passed collector is used for custom hit filtering if needed.

    Declaration
    bool OverlapCapsuleCustom<T>(float3 point1, float3 point2, float radius, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
    Parameters
    Type Name Description
    float3 point1

    The first point in capsule definition.

    float3 point2

    The second point in capsule definition.

    float radius

    The radius.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    OverlapSphere(float3, float, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)

    Checks if the provided sphere is overlapping with an ICollidable Return true if there is at least one overlap, and all overlaps will be stored in provided list.

    Declaration
    bool OverlapSphere(float3 position, float radius, ref NativeList<DistanceHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 position

    The position.

    float radius

    The radius.

    NativeList<DistanceHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    OverlapSphereCustom<T>(float3, float, ref T, CollisionFilter, QueryInteraction)

    Checks if the provided sphere is overlapping with an ICollidable Return true if there is at least one overlap, the passed collector is used for custom hit filtering if needed.

    Declaration
    bool OverlapSphereCustom<T>(float3 position, float radius, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<DistanceHit>
    Parameters
    Type Name Description
    float3 position

    The position.

    float radius

    The radius.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    SphereCast(float3, float, float3, float, out ColliderCastHit, CollisionFilter, QueryInteraction)

    Casts a specified sphere along a ray specified with origin, direction, and maxDistance, and checks if it hits an ICollidable. Return true if a hit happened, the information about closest hit will be in hitInfo.

    Declaration
    bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, out ColliderCastHit hitInfo, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 origin

    The origin.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    ColliderCastHit hitInfo

    [out] Information describing the hit.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    SphereCast(float3, float, float3, float, CollisionFilter, QueryInteraction)

    Casts a specified sphere along a ray specified with origin, direction, and maxDistance, and checks if it hits an ICollidable. Return true if there is at least one hit.

    Declaration
    bool SphereCast(float3 origin, float radius, float3 direction, float maxDistance, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 origin

    The origin.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    SphereCastAll(float3, float, float3, float, ref NativeList<ColliderCastHit>, CollisionFilter, QueryInteraction)

    Casts a specified sphere along a ray specified with origin, direction, and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, all hits will be stored in a provided list.

    Declaration
    bool SphereCastAll(float3 origin, float radius, float3 direction, float maxDistance, ref NativeList<ColliderCastHit> outHits, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
    Parameters
    Type Name Description
    float3 origin

    The origin.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    NativeList<ColliderCastHit> outHits

    [in,out] The out hits.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    SphereCastCustom<T>(float3, float, float3, float, ref T, CollisionFilter, QueryInteraction)

    Casts a specified sphere along a ray specified with origin, direction, and maxDistance, and checks if it hits an ICollidable. Return true if at least one hit happened, the passed collector is used for custom hit filtering.

    Declaration
    bool SphereCastCustom<T>(float3 origin, float radius, float3 direction, float maxDistance, ref T collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default) where T : struct, ICollector<ColliderCastHit>
    Parameters
    Type Name Description
    float3 origin

    The origin.

    float radius

    The radius.

    float3 direction

    The direction.

    float maxDistance

    The maximum distance.

    T collector

    [in,out] The collector.

    CollisionFilter filter

    Specifies the filter.

    QueryInteraction queryInteraction

    (Optional) The query interaction.

    Returns
    Type Description
    bool

    True if there is a hit, false otherwise.

    Type Parameters
    Name Description
    T

    Generic type parameter.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)