Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JulienL |
I’ve got a scene named Player
and an other named Enemy
.
Each 0.5s a new Enemy
is instancied and goes toward the Player
.
In the Enemy
script, I have a reference to the Player
with a get_node("../Player")
and get the position
from here but it makes my code brittle.
I’d like to know some alternatives. I tried to use signal but I can’t connect the Player to each new Instance. In my Main node, I have$Player.connect("has_moved", $Enemy, "_update_player_position")
it connects only to the first instance of Enemy so it doesn’t work.
Do you have any suggestions to make it work ? Thanks !