Hi, I have a main scene with player and enemies. I added both enemy and player scene under main scene in the editor. Now in script I can access the position of player with following code
$Player.position
Now the thing is I removed the player added in the editor. And now I am adding the same player at runtime by instancing it.
export (PackedScene) var Enemy
var player = Player.instance()
get_tree().get_root().call_deferred("add_child", player)
Now I try to get the position of player as follows
$Player.position
It is not working as expected.The error is
Invalid get index 'position' (on Base: 'null instance')
Any solution. Thanks in advance....