Example #1
0
        public static bool CircleCast(Fix64Vec2 center, Fix64 radius, Fix64Vec2 translation, int mask, ref PShapecastHit2D shapecastHit2D)
        {
            if (!initialized)
            {
                Initialize();
            }

            UInt16    bodyID   = 0;
            Fix64Vec2 point    = Fix64Vec2.zero;
            Fix64Vec2 normal   = Fix64Vec2.zero;
            Fix64     fraction = Fix64.zero;
            bool      hit      = NativeParallel2D.CircleCast(center, radius, mask, translation, ref point, ref normal, ref fraction, out bodyID, internalWorld.IntPointer);

            if (hit)
            {
                shapecastHit2D.point    = point;
                shapecastHit2D.normal   = normal;
                shapecastHit2D.fraction = fraction;

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

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 public static bool CircleCast(Fix64Vec2 center, Fix64 radius, Fix64Vec2 translation, ref PShapecastHit2D shapecastHit2D)
 {
     return(CircleCast(center, radius, translation, -1, ref shapecastHit2D));
 }