Getting an incorrect global position

Godot Version

4.3

Question

I'm making a mobile game. I have three objects as a part of a UI that I need coordinates of. The wide middle row, right row and an empty texture button that is over the buttons.


These three are MidRowRect, RightRowRect and TextureButton
image

	spawnpoint = get_node("VBoxContainer/HBoxContainer2/MidRowRect")
	print("Connected Spawnpoint at coordinates x: ", spawnpoint.global_position.x, ", y: ", spawnpoint.global_position.y)
	button = $VBoxContainer/TextureButton
	print("Connected TextureButton at coordinates x: ", button.global_position.x, ", y: ", button.global_position.y)
	rightRow = $VBoxContainer/HBoxContainer2/RightRowRect
	print("Connected RightRow at coordinates x: ", rightRow.global_position.x, ", y: ", rightRow.global_position.y)

I referenced them in spawnpoint, button and rightRow variables, but when I print their position I get one position for all of them

Found a way to fix this. I moved ther part of getting global position in a separate func and called it with call_deferred

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.