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?
#Enemy Ai
16 messages · Page 1 of 1 (latest)
is _physic_process a typo?
Yes.
I suspect it might behave better once that's changed (in two places) 🙂
I fixed it. But now I have error.
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.
The answer is that you want get_next_path_position, but by looking at https://docs.godotengine.org/en/stable/classes/class_navigationagent3d.html you'll be able to see that.
Godot Engine documentation
Inherits: Node< Object 3D Agent used in navigation for collision avoidance. Description: 3D Agent that is used in navigation to reach a position while avoiding static and dynamic obstacles. The dyn...
You'll generally be reading the API docs a lot while working with Godot (or any other game engine, for that matter)
Script doesn't work. Why enemy not chasing the player? How I can transfer player coordinates to enemy?
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.
Can you click on the NavigationAgent3D node and show the configuration?
I should use Area3d or just change the lines of script to enemy start chasing?