How to use get simple path

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mxt08

I am making a 3D game that I need that the enemy follows the player.
I want to use the navigation get simple path gdscript function, but I do not know how I can get and use the value.
Someone can tell me how I can do it?

:bust_in_silhouette: Reply From: Magso

get_simple_path() basically gives you an array of points, so

var the_path = Navigation.get_simple_path(start_point, end_point) #gets the path
your_player.look_at(the_path[3]) #looks at the 4th point of the path array

Typically you’ll want a KinematicBody that walks along the this path like this.

look_at(the_path[current_point]) #current_point is an int variable
if global_transform.origin.distance_to(point[current_point]) < 1:
    current_point += 1

It’s also possible to use a Path node and a PathFollow node but they’re a bit more arduous to work with in this context so I wouldn’t recommend it.