Hi, I'm trying to make an enemy who follow a path2d, and when the player comes nearby, it follow this latter. But when the player go away, the enemy returns to follow the path2d. There is a problem: the enemy does not return to the last position. It follows the path2d, but starting on the position he stopped to follow the player. The path2d is on a tileset representing a road, and the enemy should go back there after stopped chasing the player. How can I fix it?
Problem with Path Follower
From that description, I'm not sure what's supposed to happen. You'll have to be more specific, maybe show a picture to help I'm assuming you don't want it to continue where it left off, but to just get back to the path and continue from there?
If so, you can convert the enemy's position into a value along the path's curve. Something like
var value= path_2d.curve.get_closest_offset(position)
And then set that to the PathFollow2D's offset so
path_follow_2d.offset = value
Then just let it continue in whatever method you were using before.
a year later
Megalomaniak added the Godot Help tag .