Support Forum

RPG Maker style movement

How can I apply the pathfinding in a tile base map to return a set of 4 direction movements, and always move to 1 tile per step, like in Pokemon or RPG maker? I read that I can use a node base graph to do it, but how do I stop precisely at the centre of the tile(which is the node) and then make another move to the next tile?

Hi

The simplest way would be that you calculate a path as normal, and then make the agent move only to the next waypoint each step:

var path = AstarPath.active.StartPath(...);
path.BlockUntilCalculated();
var targetForThisStep = path.vectorPath[1];
GetComponent<IAstarAI>().destination = targetForThisStep;

Make sure you set the Grid Graph -> Neighbours field to “Four” instead of “Eight” which is the default.

See https://arongranberg.com/astar/docs/callingpathfinding.html