I am wondering if it is (relative easily) possible with Unity to calculate a path over grid tiles.
The concept is pretty simple; if you have chessboard, move from A->B without going diagonal.
I do have the position A and B of course, it are rounded numbers A(1,0,0) → B(4,3,0).
The only way i can think about this problem is to create a From Via To from every position to every position.
Of course (and i know) this is almost the worst possible solution.
Can someone give me a hint or tutorial? I looked into NavMeshPath but in my opinion it wasn’t very useful at all. I also watched a couple of tutorials but that didn’t help me either.
Thanks for reading and i hope someone can point me in the right direction
If you want the motion to be just that simple, and only go in two straight lines, then you just need to get the difference in X, and Y, between A and B and move on each axis in turn.
Based on your grid position A is (1,-5), and position B is (4,-2).
So from A to B, the difference is (3, 3). So starting at A, you would move 3 up, then 3 right, to arrive at B.
Anything more complicated, like obstacles to avoid, or shortest possible path, A* is the way to go.
Thank you for you quick response. I will look into A*. Never heard of this before.
Thanks
It is just an example. Maybe there will be some situations that it goes 3 up 2 left and than 1 up again, in that particular order. But it is a great starting point and indeed, it is simple.