I'm making an RPG and want to make npc ai to navigate the city. I am using polylines for collision detection, and my map is 2D, but oblique styled. I am considering using the A* algorithm to help them navigate.
I've gotten the A* algorithm to work with a top-down 2D array of nodes:
But am not sure how to go about implementing this in my game.
The overall world is 100x100 64x64px tiles, but the viewport (red box) only shows a small portion of them:
My questions are as follows:
- Do I make a 2D 100x100 array, each cell size 64x64 px to mimic the real map?
- How do I account for the polyline barriers/collision if 1's (unwalkable) and 0's (walkable) can only be assigned to a square cell?
- Performance: is it better to just created a pathing grid for the viewport, or always generate one for the entire 100x100 map?
- Barriers/Collision: I create my collision barriers directly in Tiled. Is there a way to programmatically insert
unwalkableinto the matrix for a given location of the barrier?
I am lost as to where to go next in translating this to my game.