Skip to content

Commit c160d74

Browse files
committed
prevent _ready() hang when using dynamic agent setup
Avoids waiting on already-fired `ready` signals by deferring _initialize() using `call_deferred()`. This ensures all dynamically added nodes and dependencies have completed their own _ready() methods before initialization.
1 parent 585dec7 commit c160d74

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

addons/godot_rl_agents/sync.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ var _obs_space_training: Array[Dictionary] = []
6060

6161
# Called when the node enters the scene tree for the first time.
6262
func _ready():
63-
await get_parent().ready
64-
get_tree().set_pause(true)
65-
_initialize()
66-
await get_tree().create_timer(1.0).timeout
67-
get_tree().set_pause(false)
63+
call_deferred("_try_initialize")
64+
65+
func _try_initialize():
66+
if not initialized:
67+
_initialize()
6868

6969

7070
func _initialize():

0 commit comments

Comments
 (0)