0 votes

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.

Godot version 3.4
in Engine by (77 points)

1 Answer

+1 vote
Best answer

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.

by (5,216 points)
selected by

Thank you! I catched a sence by your help.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.