Currently I am programming a 2D RTS-style game. Obviously in RTS games there is quite a bit of pathfinding going on. I am writing my code now, but I was concerned that it may not be the best solution (as I always am), so I thought I would see if anyone had any advice on my procedure.
Currently when a character is selected and given a position on the map to move to it goes through these steps:
-
Shoot a Raycast out in three directions. If the AI’s movement is to the right I set the vectors direction to (0,1,0), (1,1,0), (-1,1,0).
-
If Raycast hit returns true against a GameObject tagged as “Wall” I then create a grid of nodes and set the starting node and the final node.
-
Finally I perform A* to find the quickest path from the starting node to the final node and return an array of Vectors for the AI to follow.
This is what I am currently building. I don’t particularly have any questions about how to code this process, but rather is this a viable solution for a video game that may have up to 20 different AI moving on the screen at once? Thanks for any input and suggestions in advanced!