Node not found: "/../Player/AnimatedSprite2D

Godot Version

Godot 4


I am working on my game and im trying to set up an animation for when the Player touches the end point. I have a game manager node for things like point and general functions.
Game manager code:
extends Node
@onready var animated_sprite_2d = $“/…/Player/AnimatedSprite2D”

func endLevel():
print(“End Level”)
await get_tree().create_timer(5.0).timeout (This is allowing the animation to play)

print("End again")

I also have end point code here:
extends AnimatedSprite2D
@onready var game_manager = $“…/…/…/GameManager”
@onready var player = %Player
@onready var animated_sprite_2d = $“…/…/…/Player/AnimatedSprite2D”

func _on_end_point_body_entered(body):
if ( == “Player”):
I am just very confused on what the error is for, can it not just go from sibling node to another sibling node?

I run the code and it gives me the error in the title

List item

A leading forward slash will search from the very root of the game’s tree. I believe you just mean to use

@onready var animated_sprite_2d = $"../Player/AnimatedSprite2D"

With so many back-paths (via ../) I would recommend using @export for these references.

What does that do exactly? Im new and trying to learn from these mistakes

Nope. still has the error pop up after i deleted the leading slash

here is the whole error if this helps:
E 0:00:00:0332 @ _ready(): Node not found: “…/Player/AnimatedSprite2D” (relative to “/root/GameManager”).
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1652 @ get_node() @ _ready()

@export lets you edit the variable from the inspector, try

@export var animated_sprite2d: AnimatedSprite2D

Then selecting the node you want from the game manager’s properties in the inspector.

1 Like

That worked thank you