A* Pathfinding Project

Prevent diagonal movement in grid graph


#1

Hej!

I want the unit to move along the grid and not cut corners. I tried combine turn based hexagon example and recast navmesh example, but nothing happens. Most likely everything broke :frowning:

Little explanation below.

Thank you.


#2

Just started working with A* project myself, so still learning, but solved this by changing the number of connections from 8 to 4, and I am using the AILerp movement script, cuz it follows the path exactly, if I remember correctly. I have no idea if using a different movement script will get you the same behavior or not. Hope that helps


#3

Yes, as @Brian_Pangburn says. To achieve this behavior you should use a grid graph with the ‘neighbors’ field set to ‘Four’ instead of ‘Eight’ (‘Eight’ will allow diagonal movement).