diff --git a/scripts/smoke_test_player.gd b/scripts/smoke_test_player.gd index 02e4c0a..d631608 100644 --- a/scripts/smoke_test_player.gd +++ b/scripts/smoke_test_player.gd @@ -20,18 +20,19 @@ func _run() -> void: await process_frame print("SMOKE: loading test level scene") - # Load the test level scene (which includes the player). + # Load the test level scene (which includes the player). Use the same + # SceneTree API as the real game so `current_scene` is populated before + # the scene is added and its _ready() callbacks fire. That ordering is + # what the player's spawn lookup (get_tree().current_scene) depends on. var packed: PackedScene = load("res://scenes/worlds/test_level.tscn") - var level: Node3D = packed.instantiate() + var result := change_scene_to_packed(packed) + if result != OK: + printerr("SMOKE: failed to change scene, error ", result) + quit(1) + return - # Order matters: set_current_scene() requires the node's parent to already - # be root, so add_child() must come first. This mirrors what a real - # change_scene_to_packed() does at runtime. - root.add_child(level) - current_scene = level - - print("SMOKE: level instantiated, waiting for ready") - await level.ready + await scene_changed + var level: Node3D = current_scene as Node3D print("SMOKE: level ready") # 1. Verify the player node exists in the scene tree.