示例#1
0
    /// <summary>
    /// Wrapper for Physics.SphereCastNonAlloc to automatically display the cast volume and hits for debugging
    /// </summary>
    public static int SphereCastNonAlloc(
        Vector3 origin,
        float radius,
        Vector3 direction,
        RaycastHit[] results,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        int hits = Physics.SphereCastNonAlloc(origin, radius, direction, results, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawSphereCast(origin, radius, direction, maxDistance, SPHERECAST_COLOR, CAST_DURATION);
        DebugVR.DrawRaycastHits(hits, results, CAST_HIT_COLOR, CAST_HIT_DURATION);

        return(hits);
    }
示例#2
0
    /// <summary>
    /// Wrapper for Physics.SphereCast to automatically display the cast volume and hits for debugging
    /// </summary>
    public static bool SphereCast(
        Vector3 origin,
        float radius,
        Vector3 direction,
        out RaycastHit hitInfo,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        bool hit = Physics.SphereCast(origin, radius, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawSphereCast(origin, radius, direction, maxDistance, SPHERECAST_COLOR, CAST_DURATION);

        if (hit)
        {
            DebugVR.DrawRaycastHit(hitInfo, CAST_HIT_COLOR, CAST_HIT_DURATION);
        }

        return(hit);
    }