A* Pathfinding Project

Modifying part of the path


#1

Hi Aron,

Thank you for your work, that I find amazing.

I use your project to improve my Unity skills, but unfortunately I am stuck for many days on a problem I cannot solve.

My goal is to allow the player to modify only a part of the path : when they click on a point of the green line, all the path after is deleted, and when they click again on the map, the path is calculated only from the last click.

thumbnail_image

Is it possible to do, and would you have any advice for achiving that ?

Thank you very much !


#2

Hey,

I don’t know if there is an out of the box solution for this.
I think it’s easier for you to just generate multiple paths, based on players interaction, and combine them at the end.


#3

Hi

You can get the list of points in the path using path.vectorPath (see https://arongranberg.com/astar/docs/callingpathfinding.html). If you have both the old path and the new path you should be able to combine those lists into a new one which contains the whole path.

If you later need an actual path object you could use https://arongranberg.com/astar/docs/abpath.html#FakePath