[UNSOLVED]Can't get position of a node

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

So inside of the Enemy scene there is a KinematicBody2D called Enemy and I want to get it’s position

var poz = get_node("Enemy").position

after that I want to delete the enemy and spawn an item at it’s last position

func _on_Timer_timeout():
var spawn_drop = drop.instance()
get_owner().add_child(spawn_drop)
spawn_drop.position = poz
queue_free()` 

Invalid get index ‘position’ (on base: ‘null instance’). is the error I get
I really need this to work since without enemy’s last position the item just spawns at a far location

:bust_in_silhouette: Reply From: kidscancode

That error means that get_node("Enemy") is returning null. That means that either the node is not named that, or you have the incorrect path to the node.

get_node("SomeNode") means “Get a node named ‘SomeNode’ that’s a child of this node.” You might want to share a picture of your scene tree, but it seems that you’d probably need to say get_node("Enemy/Enemy").

![This is my tree][comment0-1]

help - Album on Imgur

WelpHelp | 2019-04-21 13:19

also tried to set position to the AnimatedSprite node of the main node(or root node?) Enemy

var poz = $AnimatedSprite.position

and it’s still Invalid get index ‘position’ (on base: ‘null instance’)

WelpHelp | 2019-04-21 23:33

Your script is attached to the Enemy node (if I understand that screenshot correctly).
Theat means “Enemy” is the node itself which can be referenced with self as well as get_node(".") but can also simple be omitted.
So it is here:
var poz = position (or var poz = self.position )

wombatstampede | 2019-04-22 15:41