예제 #1
0
        public static bool RayCast(Fix64Vec2 p1, Fix64Vec2 p2, int mask, out PRaycastHit2D raycastHit2D)
        {
            if (!initialized)
            {
                Initialize();
            }

            raycastHit2D = new PRaycastHit2D();
            UInt16    bodyID = 0;
            Fix64Vec2 point  = Fix64Vec2.zero;
            Fix64Vec2 normal = Fix64Vec2.zero;

            bool hit = NativeParallel2D.RayCast(p1, p2, mask, ref point, ref normal, out bodyID, internalWorld.IntPointer);

            if (hit)
            {
                raycastHit2D.point  = point;
                raycastHit2D.normal = normal;

                if (bodySortedList.ContainsKey(bodyID))
                {
                    raycastHit2D.rigidbody = bodySortedList[bodyID].RigidBody;
                }
                else
                {
                    Debug.LogError($"Rigibody not found: {bodyID}");
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 //raycast
 public static bool RayCast(Fix64Vec2 p1, Fix64Vec2 p2, out PRaycastHit2D raycastHit2D)
 {
     return(RayCast(p1, p2, -1, out raycastHit2D));
 }