Godot Version
4.2.2
Question
In the pig.gd I use:
@onready var player = %Player
@onready var game_manager = %game_manager
but get “Node not found” for both of them.
What’s weird:
- in the same file (
pig.gd) I use some other uniquely named nodes, and they work fine:
@onready var walk_timer = %WalkTimer
@onready var eat_timer = %EatTimer
- I have the
@onready var game_manager = %game_managerin thefood.gd. it works fine there. - For testing purposes I added
@onready var player = %Playerand@onready var game_manager = %game_managerto thered_ninja.gdand it works fine. - What’s even more weird is that like half a day ago this exact variables (
%Playerand%game_manager) were working fine in thepig.gd(the file I currently have troubles with), and now they don’t work.
Using @onready var game_manager = $"../game_manager" and @onready var player = $"../player" works, but…
I don’t want to access the node using hardcoded path like ones I just mentioned or using get_node() and still hard coding it with something like root or get_parent() or whatever.
I don’t have a clue why that is happening, seems like a bug, but maybe I’m missing something.
If someone has an idea why it doesn’t work or how to fix it — please share.
Thanks in advance.
