A* Pathfinding Project

Moving enemies around player?


#1

I am making a top down 2d game with AI that path-find to the player. If the player takes enough damage to the player then the enemies will move to the opposite end of the map, to give the player time to get back on their feet. The issue is if the player is in the path of that the enemy wants to go in, it will just get stuck on the player.

Is there a way to make the enemies path-find around the player, to avoid them getting stuck?


#2

Hey,

If you’re using the Pro version of the package you can make use of the RVO component.
Here is an example of how to add the player as obstacle for the RVO agents from the documentation:
https://arongranberg.com/astar/docs/manualrvoagentcs.html

Alternatively depending on what graph you’re using you can make use of the ITraversableInterface to block the player occupied node from being used by the agents.
Example can be found here: https://arongranberg.com/astar/docs/turnbased.html#ITraversalProvider


How to make agents avoid player?