Godot Version
4.2.2.stable
Question
Accessing Unique Names in a Singleton
Hello! I have some unique names in my scene tree, such as %Player, %GUI, and %LootGUI.
I want to access them from a GameManager script that will handle signals that each of these nodes emit.
However, the results from the GameManager are always null. I can try a direct path to each node such as “root/Farm/Player” etc, but these can change if I load into a new scene like “root/inside_house/Player” correct?
Ive tried just using get_node(“Player”) but it still returns null. Ive tried some other more convoluted workarounds like call_deferred or await, but I dont want to overengineer this if theres an easier way or some solution I’m overlooking.
The main issue that started me down this path was: I was trying to emit a signal from %Player that the %GUI and %LootGUI can both pick up on and run functions on their end. However the GUI was able to pick up the signal but the LootGUI wasnt, despite both connecting to the Player signal the same way:
%Player.connect("interact_area_leave", Callable(self, "_on_player_leave_interact_area"))
Then I figured that a GameManager script that picked up these signals and appropriately delegated the function calls out after would be more streamlined. But I still run into the same issue of not being able to pick up the %Player node.
Game Manager Singleton:
extends Node
var player : Player
var loot_gui : LootGUI
func _ready():
if player:
print(player)
SCs for context:
Any help, insight, or general feedback would be greatly appreciated! Thank you!