Implementing A* on pre-existing data

So I have been reading up as much as I can on the A* algorithm, but for the life of me I just can’t seem to figure out how to implement it into our current database. I know this is more about A* in general, but I figured it would be worth asking here. Here is the setup I have:

There are 3 Functions:
void SetDestination(IntVector2 target)
This simply sets the destination of the character to ‘target’. It also calls GetRoute on that destination.

List GetRoute(IntVector2 target, int graphSize)
This is the meat of the pathfinding. It returns an ordered list of IntVector2’s that form an optimal path to the provided ‘target’. The size of the graph it uses ‘graphSize’.

void FollowRoute(List route)
This causes the character to follow the ‘route’. It starts with the first item on the list and works its way up. If the route was not fully calculated due to the destination being outside of the graph it waits until it runs out of IntVector2’s and then runs GetRoute again.

The graph actually exists before any of this is run. It is a tile based procedural world, so every element on this graph exists before pathfinding even takes place. Each tile has a position and weight to it. The only reason I limit the graphSize is so that it only calculates a certain portion of the route at a time. That way it doesn’t have to pathfind to something a potentially infinite amount of space away. I understand this can lead to inaccuracy, but it is well within our acceptable limits and the graph size can be adjusted as needed.

So all of this is working except for, of course, GetRoute. I have read up on it quite a bit but I just can’t seem to wrap my head around it. Could anyone give me some direction with this?


So you are saying that you already have A* implemented? Or do you only have world data (but not as e.g colliders in the world)?

This page might be relevant for you: