Node not found error appears the second time I try to access a node

Godot Version

Godot_v4.4.1

Question

Hi so I am making my first game with godot to just get a feel for things after watching a couple tutorials on yt on how to work the engine. I was just trying to make a flappy bird clone and coding the score. The idea is to have the a gamemanager node that gets called every time the player passes through a pillar. The problem is however that when I pass through a pillar the second time my game throws an error and says that node not found.
image4

And this is my main scene tree and the code for the pillars (buildings)


On line 22 you are destroying the Node2D node if line 21 is true. It’s looking for the GameManager in relation to that Node2D node and can’t find it because you destroyed the node it’s searching from.

so what im understanding is when I duplicate the node, the script still gets the reference to the GameManager in relation to the origional? So then how do I ensure that the script is getting the refrence relative to the current, duplicated node?

Make your GameManager a proper autoload node instead of referencing it in the @onready.

This should solve your original problem I guess.

oh cool okay that was easy it works now thanks

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.