#Enemy Ai

16 messages · Page 1 of 1 (latest)

proven ore
#

Hello! I need help. I can't make a simple enemy AI in Godot 4 (3d). I use script from the tutorial. I bake NavigationRegion3d. Added NavigationAgent3d to enemy. Make a global script. But it doesn't work. No errors, enemy just don't moving. Why it's doesn't work?

knotty stirrup
#

is _physic_process a typo?

proven ore
#

Yes.

knotty stirrup
#

I suspect it might behave better once that's changed (in two places) 🙂

proven ore
#

I fixed it. But now I have error.

knotty stirrup
#

It's another mis-name. The best thing to do here is to look at the docs for NavigationAgent3D, and work out where you went wrong.

#

You'll generally be reading the API docs a lot while working with Godot (or any other game engine, for that matter)

proven ore
#

I fix it. Enemy don't moving. But now I can see player coordinates.

proven ore
#

Script doesn't work. Why enemy not chasing the player? How I can transfer player coordinates to enemy?

stiff zenith
#

The simplest approach is to have an Area object detect and store a reference to the player body node. Once you have that set up, you can then query it for the player's 'global_position' whenever you need it.

But, if you need to know the player's coords right away, you can move the getter method to an autoload object and have your player script upload its reference when it enters the scene. Or, if you don't want to use a singleton, you can also implement this through a shared custom resource as well.

#

Alternatively... you can also just make the area's collision shape really large and avoid the second method altogether.

lean wolf
#

Can you click on the NavigationAgent3D node and show the configuration?

proven ore
proven ore
#

I should use Area3d or just change the lines of script to enemy start chasing?