endPoint != originalEndPoint and still no error?

I’m building a tower defense game with the grid graph and every time i put down a tower i update the graph and make my seeker units recalculate their path. My problem is, that if i block the path with the towers the path returned will look like this:

so as you can see, the endPoint and originalEndPoint are not the same. Shouldn’t this result in an error in the path?


This is usually the desired behavior (for example in an RPG game with click to move controls the player might click on a spot just slightly outside the navmesh, the character should then move to the closest spot it can reach).
If you want to reduce this distance you can change the A* Inspector -> Settings -> Max Nearest Node Distance setting.

Also see http://arongranberg.com/astar/docs/graph-updates.php#blocking

Alright, thanks alot.

I have already implemented the blocking handling you linked to :slight_smile:

My current problem is that every time i put down a tower i want the path for each of my units to be recalculated. When the path is recalculated the units are likely to have moved a little since the request was sent and i get this “laggy” behavior where the units walk backwards. Except from that, the script is amazing, nice work :smiley:

Edit I think i found a way to get rid of the laggy behavior. When receiving the updated path i check which checkpoint i am closest to and add 1 to that. It’s a hack, but it seems like it works :slight_smile:


The included movement script (AIPath) will simulate movement from where the path was requested to where the character is now to avoid that problem. You can take a look at that code if you want.