Topic was automatically imported from the old Question2Answer platform.
Asked By
Mxt08
Hi!
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?
Thanks.
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.
move_and_slide(global_transform.basis.xform(Vector3.FORWARD))
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.