Hi!
Are there any tricks to making flee path more accurate in where it paths to? I’m trying to create an archer AI in a turn based game where they run to maximum range of their attack away from the enemy. Problems I’m having right now are that sometimes the AI moves for only about 1 unit and sometimes it moves past the maximum range.
Here’s my current code:
public IEnumerator MoveToMaxRange () {
float range = chosenAbility.Range - 0.5f;
Vector3 direction = transform.position - target.transform.position;
Vector3 destination = target.transform.position + (direction.normalized * range);
FleePath path = FleePath.Construct (transform.position, target.transform.position, (int) range * 1000);
path.aimStrength = 99;
path.spread = 600;
path.aim = destination;
Seeker seeker = GetComponent<Seeker> ();
characterMovement.ai.isStopped = false;
characterMovement.ai.canSearch = false;
characterMovement.ai.SetPath (null);
seeker.StartPath (path);
yield return StartCoroutine (path.WaitForPath ());
while (!characterMovement.ai.reachedEndOfPath && !characterMovement.ai.reachedDestination && CanMove ()) {
yield return null;
}
MovedThisTurn = true;
}