Hi! I was wondering if anyone knew how to get an object to run away using pathfinding. The context is that I want enemies to run away when they're on low health. I just dont know how I could apuire the position to move to.
With all things Id like to keep this system dynamic if possible. Thank you!
Develop games in your browser. Powerful, performant & highly capable.
You need to define what away is. For example, away could be: somewhere between 500-600px in a 360° area from current position, not overlapping an object.
Then when it is time to trigger the enemy to pathfind away, you can use that logic to set the pathfind destination.
My apologies, When I say away I mean I want the enemy to find a position thats not overlaping an object, maybe 1000px away thats in the opposite direction to the player.
use find path to
X=self.X+cos(angle(player.x,player.y,self.x,self.y))*1000
Y=self.Y+sin(angle(player.x,player.y,self.x,self.y))*1000