Looking for help with multi-select item drag logic

Godot Version

4.3

Question

I think I’m making a simple mistake with my multi-select code, but I just cannot figure it out. It’s also the last big issue I have with the game, so fingers crossed someone can provide some insight!

The concept: In my decorating game, when the player is in Multi-Select Mode, they can draw a yellow rectangle over a group of items, then click within the rectangle and move that group as one unit. When they release, the items retain that new position and the rectangle goes away, allowing the player to draw a new rectangle if they want.

The problem: the items are not moving at the same rate as the player drags them as a group. Here’s a visual example:

Above, the player has drawn the yellow rectangle around the items and expects them to all move together when dragging. But here’s what actually happens:

Instead, the items move at different rates (the rectangle has gone away because I released the mouse before taking a screenshot- but they look like this as the player is dragging.)

My dragging code:

Drawing the rectangle works fine- the problem only starts when I start dragging. Below is my code for that.

#Drag Actions

func confirm_dragging(event):
  #confirm that the mouse click (event) was within the rectangle (selection_rect)

  if selection_rect != null and selection_rect.has_point(event):
    print("mouse was clicked within the rectangle")
    ReadyToDrag = false
    DraggingGroup = true
    DragOffset = event

  else:
    print("mouse was clicked outside the rectangle; will reset")
    queue_redraw()
    selection_rect = null
    DraggingGroup = false
    ReadyToDrag = false
    clear_items()

func update_dragging(event):
  #this code updates the position of the items & rectangle as the player drags (mouse event is 'event')

  var NewPosition = event - DragOffset
  for item in GroupToMove:
    item.global_position += NewPosition

  selection_rect.position += NewPosition
  DragOffset = event
  queue_redraw()

I think I sorted it out, actually- I wasn’t tailoring the drag offsets to each individual item, so I ended up adding an item_offset dictionary, populating it upon “confirm drag,” then used it to update each item’s position during “update_dragging” in the for loop, rather than adding the same drag_offset to each item.