The actual coordinates that define a polygon are actually local, the position of Polygon2D
doesn't automatically shift all the coordinates defined by the polygon for it to be represented in global coordinates, you can use an overridden xform
method for translating an array of points.
Edit: transform_points_2d
is removed since 3.2.beta in favor of xform
, see this PR.
if event.is_action_pressed("leftclick"):
var trans = Transform2D(0.0, get_global_mouse_position())
var polyB = trans.xform(adder.get_polygon())
mergeResult = Geometry.merge_polygons_2d(levelVec2, polyB)
Similarly the levelVec2
polygon needs to be transformed perhaps.
Also, merge_polygons_2d
will return an empty array if neither polygon overlap.