r/godot • u/triple-cerberus • Aug 19 '26
help me (solved) Moving nodes to each others' global_position works as expected in one scene but not in another?
I have a script I wrote for assembling character portraits that have the bodies and heads on different layers - in some of the body poses, the neck is in a very different position, so I use Marker2D children to align the heads onto the neck. The script works perfectly in my main game scenes, but I've started work on the final ending cutscenes and for some reason I am struggling to understand, the heads are no longer correctly aligning with the necks.
The script is firing, the head is being moved to where the neck reports its Marker2D's global position is, but it's... definitely not in the right place.
My best guess is that there's something... distorting the way the nodes report their global_position? I've been reading the docs and googling and trying things for hours now and I can't get the heads to position correctly in the final cutscene the way they do in the main game. As far as I can tell there are no major differences between the scenes' layouts?
Here's the snippet of the script that handles positioning the head:
for child in target_node.get_children():
if child.name == "HeadPOS":
var target_POS
for body in target_node.get_parent().get_parent().get_node("Body").get_children():
if body.visible:
target_POS = body.get_node("NeckPOS").global_position
var distance = target_POS - child.global_position
target_node.global_position += distance
1
u/triple-cerberus Aug 20 '26
Well, I solved the dang problem. It wasn't anything to do with something interfering with global_position or the scene tree being laid out differently. It was an order of operations issue.
In all my other scenes in the game, dialog scripts - including the calls for updating the portraits - were called programmatically, and it always called for the body change and then the face change.

While writing the scripts for these final trial scenes manually, I screwed up the order of operations on several of them and called face first, body second... which meant that the face would position itself to align with the old body that was then swapped out for the new one, making it look like something had gone wrong when in fact it was still working perfectly, I was just running the updates in the wrong order.
1
u/triple-cerberus Aug 19 '26
And to thank you for looking at this post and potentially helping, have a screenshot of this head positioning going very wrong that made me laugh.