The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+2 votes

Just started using Godot and I have a very basic understanding of how to code in it. Right now I have a 2d top down game I am working on and I am having trouble with the enemy AI.

I have looked up countless videos about pathfinding and I cant figure out how to get what I want to happen work.

Currently my enemy will roam about on his own freely. When the player steps in the collision area of the enemy I had some code setup to where the enemy would then chase the player. That was great but I need to get that code to work with pathfinding so the enemy does not collide with walls and will step around them.

I now have a tile map setup with flooring that has a Navigationpolygon instance on it. and in the main scene it is a child of a Navigation2d

If anyone could help explain how to use getsimplepath properly so the AI follows the player avoiding collisions I would be very greatful.

in Engine by (14 points)

1 Answer

+1 vote

KidsCanCode made a great tutorial for this. I believe he describes exactly what your are looking for in detail:

by (26 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 [email protected] with your username.