- Home /
PATHFINDING in a grid game
I want make an easy pathfinding for turn based tactical game. I dont need any dynamic search or navmesh etc... I have a grid, I have a 2d-array (0 - empty cell, 1 - occupied one). The path is to the center of each cell. Can anyone explain the algorithm? and some examples... And how can I render the path line? Thanks.
Answer by Slev · Nov 18, 2014 at 04:28 PM
I'd recommend something like Primm's or Dijkstra's algorithm as it will find you the shortest path. You can find more info on path finding here: Pathfinding
For rendering lines in Unity you could use a LineRenderer or purchase Vectrosity, which will allow for Debug-style line drawing in the game. (And many other features.)
Answer by Cherno · Nov 18, 2014 at 05:05 PM
Lines can be drawn with something like this script: http://wiki.unity3d.com/index.php?title=DrawLine
As for Grid-based pathfinding, you might save yourselfe a lot of work by just using Aron Granberg's Astar Pathfinding Project, it comes with support for Grid Graphs.
Your answer
![](https://koobas.hobune.stream/wayback/20220613171835im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Draw grid and check colisions with other objects for every cell 1 Answer
Pathfinding unity 3 Answers
A* Pathfinding Grid 1 Answer
RTS Grid Initialisation 0 Answers
Pathfinding movable area on a grid with varying movement costs 1 Answer