Hello all,

I have some questions about the global_position method.

In my code I have a signal calling the _on_line_removed() method, this is the text for debugging purposes:

func _on_line_removed(YPos):
	print("YPos" + str(YPos))
	print("wallPosition" + str(wallPosition))
	print("y global Position" + str(global_position.y))
	finalPos = Vector2.ZERO
	label.text = (str(global_position.y))

The output looks like this:

YPos240
wallPosition256
y global Position768

the label output at screen looks like this:
(please note that the wallPosition is y Coordinate of the below wall, and the YPos position is the line that got removed by the Tetris game):

I thought that the global position would give me the node position relative to the root node, but I dont understand why the label is giving me a diferent value than the output.

Here the current node structure:

The code with the above method is in a singleBlock instance.

I checked and all Node2d transforms are 0,0 before getting into the screen, so there should be no offset.

Can somebody point me to the correct direction? What am I missing? I think it is a bug in my code... but I am not getting to debug this properly.

Thanks for all the help.
Sinith

    sinithparanga I don't understand why the label is giving me a different value than the output.

    Are you sure that the label referenced in that code is the same one in the image?

    Do multiple nodes share the same script?

      DaveTheCoder

      I got the problem, I was moving the parent node and therefor the childs global position was moved as well, and my guess is that the movement of the parent happened between the label.text print and the output. or something like that.

      this all nodes and node structure in Godot needs some refactoring of my code. it is completely different to Unity.