#Intelligent AI flee state
1 messages · Page 1 of 1 (latest)
Do you use pathfinding/navmesh?
A simple fix would be to check if the flee position is out of bounds and just find a new random position with brute force.
The thing is what if this new random position is toward the chasing entity? Seems unrealistic
You can sample a few positions and score them by distance to the player and pick the one with the best score
^ definitely just check a few places and should nothing work that does not require going toward the player, have a cornered state
Good idea
How would you check if your cornered
I don’t suppose there’s something navmesh related?
If it can't move away from the player after so many random attempts it can consider itself cornered.
Cleverly finding the best way to escape from an enemy is a bit tricky!
I've done this by randomly sampling points and snapping to the nearest part of the navmesh, then scoring them based on how close they are to a threat
But you really want to be able to avoid where the enemy is going, too
So you might throw in score based on distance from their expected position
this can get expensive
So here is my idea
We have a bunch of points on the navmesh, let’s say we raycast hit a border wall. Now we check for points in an area, for each point we check if the enemy is closer to it then the fleeing npc, if it is then we find another point. Once we find a point we can select that as our new destination. Once we are no longer raycast hitting with a border wall we can return back to our previous state
@lament gulch @modern quest @low quail @slender sorrel thoughts?
Deciding when it stops depends on why the NPC was fleeing in the first place. Is it still being actively chased? Is there a distance threshold? Stamina? Line of Sight? Timer?