Esempio n. 1
0
 internal static Collider[] GetQueryResult()
 {
     Collider[] cols = colliders.Take(colliderCount).ToArray();
     colliderCount = 0;
     layermask = Physics.kDefaultRaycastLayers;
     breakOnFirst = false;
     return cols;
 }
Esempio n. 2
0
        public static bool CheckCapsule(Vector3 start, Vector3 end, float radius, LayerMask layermask)
        {
            //TODO an actual capsule check.. not just a raycasts
            Vector3 forward = (end - start).normalized;
            Vector3 right = new Vector3(forward.z,0,-forward.x);

            Ray middleRay = new Ray(start, forward);
            Ray rightRay = new Ray(start + right * radius + forward * radius, forward);
            Ray leftRay = new Ray(start - right * radius + forward * radius, forward);

            float middleLength = (end - start).magnitude;
            float sidesLength = middleLength - radius * 2;

            return (Raycast(middleRay, middleLength, layermask) || Raycast(rightRay, sidesLength, layermask) || Raycast(leftRay, sidesLength, layermask));
        }
Esempio n. 3
0
 public static bool SphereCast(Ray ray, float radius, float distance, LayerMask layerMask)
 {
     AABB aabb = new AABB(ray.GetPoint(distance / 2), distance, radius);
     QueryHelper.layermask = layerMask;
     QueryHelper.breakOnFirst = true;
     world.QueryAABB(null, ref aabb);
     return QueryHelper.GetQueryResult().Length > 0;
 }
Esempio n. 4
0
 public static Collider[] OverlapSphere(Vector2 position, float radius, LayerMask layermask)
 {
     AABB aabb = new AABB(position, radius, radius);
     QueryHelper.layermask = layermask;
     world.QueryAABB(null, ref aabb);
     return QueryHelper.GetQueryResult();
 }
Esempio n. 5
0
        public static bool CheckLayerMaskContainsLayer(LayerMask _mask, int _layer)
        {
            LayerMask _contains = 1 << _layer;

            return LayerMaskOperations.CheckLayerMaskOverlap(_mask, _contains);
        }
Esempio n. 6
0
 public static bool CheckLayerMaskOverlap(LayerMask _mask, LayerMask _contains)
 {
     return ((_mask & _contains) == _contains.value);
 }