Topic was automatically imported from the old Question2Answer platform.
Asked By
xXDMOGXx
I have been looking around, and I can’t seem to find an answer that works for me. I have a 3d enemy that I want to make constantly look at the player as long as they are in its area. I would appreciate if someone could write a short sample code or something.
I haven’t tried developing in 3D but I have encountered this problem in 2D when I wanted zombies to keep looking at my player whenever my player can be seen. And I have found the answer here. Only for 2D though but I hope it helps.
Basically, subtracting the position of the zombie and my player then normalizing it will give out the vector pointing to the direction of my player. Go ahead and give the link above a look and you’ll know what I’m talking about.