- Home /
Pathfinding across a map
I don't know exactly how to explain this, but, I'm attempting to make a game where a user controls a nation. The game basically consists of a map, which consists of nations, which all control different provinces, which are defined in a bmp file where each is represented by a different color, (here is a screenshot of part of the file, I could not send the whole thing as it was too big) One of the primary game functions is soldiers, which can be moved across these provinces and used to occupy enemy territory or preform other similar tasks. For these soldiers to be able to move across this map, I need them to be able to find a path to the target province. I have not experimented much with path finding before, but from what I understand a path finding algorithm like A* or Dijkstra’s Algorithm would be what I need to use, and that these algorithms require nodes, representing the locations, and connections to function. The nodes would then, in this case, have to be somewhere in the province near the center, and as I found this to be rather too complicated to produce using C#, I made another map (here is a screenshot of part of that one)
, where the nodes are represented by black pixels, and I plan on creating a script that checks which pixels are black and set these to nodes. From here, the only thing left for me would be connections. I now require a way to determine connections, and I honestly have how I would do this. I would greatly appreciate if anyone could present to me a solution, and thank you in advance!
Your answer
![](https://koobas.hobune.stream/wayback/20220612222306im_/https://answers.unity.com/themes/thub/images/avi.jpg)