This is a problem with two game objects (none controlled by the player) are always searching for each other, and when they are within a distance they set their targets to each other and then stop when very close, much like the minions in league of legends.
This works fine up until one has to “Budge” out the way for another to get close, then they start just floating away in the direction they was pushed? I like that they are budged out the way so they all surround the enemy / minion, however i dont want them all floating and all slowly being pushed away from each other? The code for the finding and stopping is below, any help will be grand!
foreach (GameObject targetEnemy in minionManagerScript.enemyMinionList){
if ((Vector3.Distance(this.gameObject.transform.position, targetEnemy.transform.position) < 10f)) {
thisFightersPath.agent.SetDestination(targetEnemy.transform.position);
}
if ((Vector3.Distance(this.gameObject.transform.position, targetEnemy.transform.position) < 1.5f)) {
thisFightersPath.agent.Stop();
isAttacking = true;
}
}