Exemplo n.º 1
0
    public static bool Raycast(
        Vector3 origin,
        Vector3 direction,
        out RaycastHit hitInfo,
        float maxDistance,
        int layerMask = -1,
        QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal
        )
    {
        bool hit = Physics.Raycast(origin, direction, out hitInfo, maxDistance, layerMask, queryTriggerInteraction);

        DebugVR.DrawArrow(origin, origin + (direction * maxDistance), RAYCAST_COLOR, CAST_DURATION);

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

        return(hit);
    }
Exemplo n.º 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);
    }