top of page

Unity AI Pathfinding

Each unit weilds a specific type of weapon like an axe, sword or spear. In here axe beats spear, spear beats sword and lastly sword beats axe so its like rock paper scissors. Using this weapon triangle I make the AI pick a favourite target.

The blue ring is its Djikstra search showing the range that its searching for its target and the black is the A* search to its discovered target from the Dijsktra search.

The red are buildings, the purple are difficult terrain that slows down movement.

In this picture I switched the original targets weapon from a spear to a sword so once the Djisktra search finds an unfavourable opponent to go against it will search further out for a more favourable target. But if their are no other targets in that range then go after that target since it isnt always completly one sided even if it is losing in the weapon triangle.

This is to show how it will pathfind around buildings and difficult terrain based on the unit type it is.

Now in here I switch my unit type to one that can fly and he found a better target that was closer and can go over most different types of terrain except for some difficult area like huge trees that are being represented in purple above.

In this example it will show what happens if there is fog in the map making it difficult to find a target so he will search in a small range and will try to find a target.

bottom of page