WIP checkpoint: PC2: Basic visible player character representation
This commit is contained in:
+11
-3
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user