can't access node with get_node()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PrOoOg
:warning: Old Version Published before Godot 3 was released.

the script is attached to the “ennmy_sprite” sprite.
here is the scene tree:

and here is the code:

extends Sprite

var player_sprite

func _ready():
	player_sprite = get_node("/root/player/player_sprite")
	set_process(true)
	
func _process(delta):
	if player_sprite:
		print("player_sprite")

i’m having : error Node not found

:bust_in_silhouette: Reply From: YeOldeDM

You’re forgetting the top node in your scene in your path to player_sprite:

get_node("/root/Level/player/player_sprite")

thanks, I thought that the scene node is the root path.

PrOoOg | 2017-06-30 18:56