Godot Version
4.3
Question
I have a tasklist with hierarchical lines where each task is a scene:
The root task(in the above image is the first task) is the only scene that has a _traverse_tree()
function, it uses global_position()
of the tasks to create points and draw lines with draw_multiline()
of all existing tasks when any new task is added (by pressing the “+” button). If a non-root task adds a new subtask it calls the root task _traverse_tree()
then doing the SAME logic as the root task. The problem occurs when I add a subtask from a non-root task (meaning a child scene) and the task list has previously added tasks after the new task.
The solution I found is using await get_tree().create_timer(0.005).timeout
, but as the task list grows, a longer delay is needed, therefore doesn’t seems to be a good way of dealing with it. I tried to use call_deferred("_traverse_tree")
however the problem still persists. What should I wait before updating the points in the root CanvasItem? What function to use so the new child scene has an updated global_position? How godot updates global_position with nested scenes?