mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-12 02:13:42 +00:00
fix(hud): have game mode hand HUD its target ship instead of group lookup
HUDController found its ship via get_first_node_in_group("ship"), a group
that has 2+ members once a match has an AI opponent — it only worked
because the player ship happened to spawn first. spawn_camera_rig now
wires the HUD's ship the same way it already wires the camera rig's
target.
This commit is contained in:
@@ -13,6 +13,7 @@ extends Node3D
|
||||
const CAMERA_RIG_SCENE = preload("res://scenes/ship_camera_rig.tscn")
|
||||
|
||||
var arena: Arena
|
||||
var hud: HUDController
|
||||
var ball: RigidBody3D
|
||||
var ships: Array[Ship] = []
|
||||
var _ship_spawn_transforms := {}
|
||||
@@ -30,7 +31,8 @@ func _ready():
|
||||
for child in get_children():
|
||||
if child is Arena:
|
||||
arena = child
|
||||
break
|
||||
elif child is HUDController:
|
||||
hud = child
|
||||
if not arena:
|
||||
var path := _get_arena_scene_path()
|
||||
if not path.is_empty():
|
||||
@@ -99,6 +101,10 @@ func spawn_camera_rig(target: Ship) -> ShipCameraRig:
|
||||
var rig: ShipCameraRig = CAMERA_RIG_SCENE.instantiate()
|
||||
add_child(rig)
|
||||
rig.target = target
|
||||
# Also wires the scene's static HUD (if any) to the same ship, rather
|
||||
# than letting it guess via the "ship" group.
|
||||
if hud:
|
||||
hud.ship = target
|
||||
return rig
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user