Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | UserWaitingForGodot |
I have a scene setup like these:
Parent
Pepe
Juan
Pedro
Luisa
(each one being a Node2D)
Each child of Parent has the same scrpit:
extends Node2D
var timer: = Timer.new()
func _ready():
timer.autostart = true
timer.wait_time = 1.0
add_child(timer)
timer.connect("timeout", self, "on_timeout")
print(get_path(), " is at position ", get_position_in_parent())
func on_timeout():
if get_position_in_parent() == 0:
print(get_path(), "'s turn")
get_parent().move_child(self, get_parent().get_child_count()-1)
else:
print("is not ", get_path(), "'s turn")
In the first frame, the print output is okey:
(Pepe is at position 0,
Juan is at position 1,
Pedro is at position 2
Luisa is at position 3)
However, when the on_timeout function gets called every second, every node has the condition get_position_in_parent() == 0
set to true. How can the have the same position in the same parent?