I'm trying to use reparent but I get an error after reparenting.
func on_redBalls_pressed(viewport, event, shape_idx):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and not event.is_echo() and event.is_pressed():
print("pressed")
temp_parenting($RedBalls, $RedZone)
func temp_parenting(child, new_parent):
for i in $RedZone/RedPositions.get_children().size():
if child.global_position == $RedZone/RedPositions.get_child(i).global_position:
var old_parent = child.get_parent()
old_parent.remove_child(child)
child.position = $RedZone/RedPositions.get_child(i).position
new_parent.add_child(child)
new_parent.set_owner(child)
break
When the method called first time works, but then I get error when the function called the second time because "child" is null.