0 votes

I need any help or other idea for 3D enemy search Player till collision

thank you

in Engine by (101 points)

2 Answers

0 votes

I dont know what a "3D Raycast Enemy" is but to follow something is the classic TranslationA-TranslationB to get the distance.

For smooth approach you can make a linear interpolation of the positions, advanced following may require to design a steering behaviour (like pursuit).

For basics of movement, this tutorial covers many things in godot:

If you are interested in the advanced (but simple) techniques you can read about steering behaviours here (is generic):

by (7,832 points)
0 votes

The enemy is a script that knows the whole scene. Thus you can calculate player.translation-self.translation to have a vector that points directly to the player with the distance between them. No need for a raycast for that. Also, you can do this with Transforms and their method Looking_at.
But I guess it's not what you want, right? I think you're not only asking for a raycast but for a whole AI that can move and detect collisions.

by (698 points)

look please enemy not on the world yet.when i walking in same area of map enemy is add with add_child but how enemy will get my position for rotate to my direction and how he will detect my distance is not with RayCast?


He'll get your position with a getnode of your player's node. Since his node and the player's node must be on the scene, then a getnode of the player from this scene will give you the possibility to get then the global transform of the player. And since you can do that within the script of the enemy, you simply need to substract the translation vector of the enemy from the translation vector of the player, and the resulting vector gives you the direction to the player.
Excuse me to ask, but I've the feeling you're uneasy with vector maths. If it's the case, you should maybe check godot's doc, chapter about vectors.

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 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.