Enemy AI, Follow Player without getting stuck on walls?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kavi
:warning: Old Version Published before Godot 3 was released.

Hello! Is there any simple way to make an enemy KinematicBody2D follow the player and make it so he doesn’t get stuck at a wall, and just finds his way around?

(Ex: An overhead game with a zombie, and the zombie follows the player and when he reaches a wall, just goes around it?)

Some help/Ideas would be nice.

:bust_in_silhouette: Reply From: volzhs

There is Navigation2D and NavigationPolygonInstance for finding path.

here is sample project.

you can find it also on download page. Download - Godot Engine
Download “Demos and Examples” and import demo/2d/navpoly

I’d like to add the OP also check out the Kinematic Body tutorial to deal with sticking to the walls of the enemies happen to run into them.

Kinematic Body Tutorial

2D||!2D | 2017-05-07 00:09

On a top down view, how do I get the Zombie sprite to have it’s arms move to the player? Having a hard time getting the sprite to rotate to the direction of the player as I’m trying to make a top-down shooter.

PlayItForward | 2018-03-18 11:28