WIP checkpoint: PC2: Basic visible player character representation

This commit is contained in:
2026-08-21 00:06:54 +00:00
parent 945c498a31
commit 5966fa9044
2 changed files with 41 additions and 28 deletions
+11 -3
View File
@@ -34,11 +34,19 @@ func _ready() -> void:
# scene root. The lookup walks the full subtree (recursive=true) so
# it finds the marker whether it is a direct child of the level or
# nested deeper.
var spawn := get_tree().current_scene.find_child("PlayerSpawn", true, false)
#
# current_scene is null in headless --script mode and in any scene
# before the main scene is fully swapped in, so guard it rather than
# blindly dereferencing.
var current_scene: Node = get_tree().current_scene
var spawn: Node = null
if current_scene != null:
spawn = current_scene.find_child("PlayerSpawn", true, false)
if spawn is Node3D:
global_position = spawn.global_position
global_position = (spawn as Node3D).global_position
# Align player forward with spawn yaw (optional polish).
var spawn_yaw := spawn.rotation.y
var spawn_yaw := (spawn as Node3D).rotation.y
rotation.y = spawn_yaw
else:
push_warning("player.gd: no PlayerSpawn marker found; spawning at origin")