0 votes

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.

in Engine by (15 points)

1 Answer

0 votes

Hi!

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.

https://docs.godotengine.org/en/3.1/tutorials/math/vector_math.html

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.

by (104 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.