You need to get the player on the Angel script, get its position (object.position), get the angel position, calculate where the angel should move and make him move.
The laziest and fastest (faster to you do, the performance is the same) way to get the player's position on the angel's script would be using get_parent()
and get_node()
on the angel's script but if you do that, you can't rename the player node or change the player and angel parent.
The other way would be creating a singleton (global script), then creating a variable in the singleton like player_positon
then in the player script, in _ready()
, you would need to do (assuming that the name of the singleton is "Global") Global.player_position = self.position
.
Ok. Now you have the player position in the desired script. Now you need to calculate where the angel should go. I don't work on 3D right now, so I can't help you with that, but I think that you would need to turn the angel so he is "aiming" at the player. If there are walls or something like that between them, I really don't know how to help you with that.
Then you will have to move the angel. As I said, I don't work with 3D, so I'm not sure how you will do that but I think that move_and_slide()
will do the job.
It's probably a little confusing, sorry about that, I kinda that lost myself in the middle.
If you have more doubts, let me know.
Good Luck!