invalid get index "position" on base null instance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Keby

Hello, I have a problem with a path node it saying that the path is null
I have a script called Enemy and I’m trying to get Players node position but it’s not working

extends KinematicBody2D

func _physics_process(delta):

I also tried printing out the node path without the position it says [Object:null]

:bust_in_silhouette: Reply From: magicalogic

According to this using absolute paths with get_node() requires the node to exist in the Scene tree. Your node is either note in the scene tree or your path is incorrect.

:bust_in_silhouette: Reply From: Keby

I fixed it, the issue was that I typed root/ instead of /root/ and also .position() doesn’t work.

extends KinematicBody2D

func _physics_process(delta):
	var pos = get_node("/root/MainScene/Player")
	var pos2 = pos.position