Retreat enemy from player with Astar2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By HorseGorilla

Hello, I’m really in a mess due to AStar2D.

The problem is that my pathfinder finds a way by converting it to points based on position.

But that position is usually the player’s position, so how do you move away from the player?

Multiply by (-1), so if the player is still, mob will be the same. If we simply get the direction, we don’t know the location of the structure and it will collide.

Any help in resolving the problem would be greatly appreciated! and sorry for my sloppy writing with a translator.

:bust_in_silhouette: Reply From: Inces

It is not a problem of Astar, but of general design and planning. You always have one target when in pursuit, but the fleeing has endless amount of targets. You have to choose how enemy should be retreating, pick some algorithm to actually choose one of those endless targets and build path from it. For example : if walls are far away find path to tile that is farthest form player, but if walls are too close find path to closest room, that is farthest from player.

Thank you! I catched a sence by your help.

HorseGorilla | 2021-11-22 12:31