private static object _OverlapCapsule(FPVector2 point, FPVector2 size, FPCapsuleDirection2D direction, FP angle, Physics2D.BodySpecialSensor sensorType, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { if (direction == FPCapsuleDirection2D.HORIZONTAL) { FP aux = size.y; size.y = size.x; size.x = aux; angle += 90; } FP radius = size.x * FP.Half; Physics2D.Vertices capVerts = Physics2D.PolygonTools.CreateCapsule(size.y, radius, 8, radius, 8); Physics2D.PolygonTools.TransformVertices(capVerts, point, angle * FP.Deg2Rad * -1); return(OverlapGeneric(new Physics2D.PolygonShape(capVerts, 1), point, sensorType, layerMask)); }
/** * @brief Returns all {@link FPCollider2D} within a capsule area. Returns null if there is none. * * @param point Center of the capsule in world space. * @param size Size of the capsule. * @param direction If it is a vertical or horizontal capsule. * @param angle Rotation angle in degrees of the capsule. * @param layerMask Unity's layer mask to filter objects. **/ public static FPCollider2D[] OverlapCapsuleAll(FPVector2 point, FPVector2 size, FPCapsuleDirection2D direction, FP angle, int layerMask = UnityEngine.Physics.DefaultRaycastLayers) { return((FPCollider2D[])_OverlapCapsule(point, size, direction, angle, Physics2D.BodySpecialSensor.ActiveAll, layerMask)); }