0 votes

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?

in Engine by (353 points)

1 Answer

+1 vote
Best answer

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.

by (3,239 points)
selected by
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.