ps: Player is placed in the main scene as a node.
But my enemy scene get instanced more then once at the main scene as enemy1. and get instanced randomly.
Use get_parent ().
If the player is the enemy’s brother (both are within the same node) get_parent().get_node("Player").position
Will resolve
Example of tree:
Root
.Node
…Player
…Enemy
…Enemy
If you use get_parent() in enemy script, will return his father who is Node.
This way will also solve. no need to get_tree().get_root()
get_node("Node/Player")
Firty | 2020-10-30 17:57
well thank you for anwser but i think i didnt expres the problem correcly,
this is my enemy scene :
and this is my main scene :
im trying the get player position from the script attact to enemy1.
so that i can made enemys to look at the player, and follow them. whlie im not sure if it will be work or not, cause there are more then 1 instanced enemy1 at the scene.
morningkingdom | 2020-10-30 18:35
It will work even with 1000 instanced enemies.
You have to obviously change from player to karakter.