Move a Control to a different parent but keep the old rotation

Godot Version

4.4-dev1

Question

Hello everyone and hope you are doing fine :slightly_smiling_face: I’m learning Godot and would like some help with something I’ve been stuck at.
I want to move a Control to a different parent but would like to keep the old transform. I used
card.reparent(dest, true)
but this seems to keep the position only (confirmed with the documentation). The destination parent is rotated and how matter how much I play with rotation and offsets it seems to never keep the old position and rotation. Anyone has faced this before?

You can save the rotation before and then apply it again later, right?

The rotation is always 0, it gets rotated because of the new parent transforms.

And whats the problem with just setting it to 0 after reparenting?

Does this help maybe? https://www.reddit.com/r/godot/s/57uoVxyzwz

I added an image to explain what I’m trying to achieve. I’m building a card game and I want to tween a card between the deck and the hand.

This didn’t seem to help. The card always ends up in the top left corner of the screen.

It will something like this if you want to keep the rotation same even if it change its parent.

var rot = 0 #that you want as default to keep
rotation = rot - get_parent().global_rotation
1 Like

Thx for the suggestion. So that doesn’t work because of the card pivot offsets. However if I set them to (0, 0) it works. However when I put them back the card changes position drastically.

1 Like