Moving a node as if the child was the parent

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarlowrey
:warning: Old Version Published before Godot 3 was released.

Typically when you move a parent it’s children move along with it. I want to be able to move a child and have its parents move (up to a point, don’t want to move root or the viewport). Is there a way to do this? Should I switch the child/parent role and then switch back, does that cause any weirdness/data loss?

:bust_in_silhouette: Reply From: jarlowrey

This works perfect! Avoids all messy/dumb reparenting stuff and works no matter how many parenting layers are between parent and child

var diff = get_global_pos() - my_child.get_global_pos()
set_global_pos(other_node.get_global_pos() + diff)

This doesn’t work for me.

sairam123 | 2021-04-23 13:25