- Home /
GameObject 'floats' when pushed by another object after calling NavMesh stop() ?
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;
}
}
Answer by Taorcb · Nov 10, 2015 at 03:30 AM
From what I understand about NavMeshAgent.Stop(), it's the equivalent of disabling the NavMeshAgent on your AIs, so physics will have full reign over what happens to them. Try setting their destinations to their positions (NavMeshAgent.destination = transform.position).
Your answer
Follow this Question
Related Questions
Does NavMeshAgent disable a gameObject's collider? 1 Answer
Why is my navmesh a 3d (taller than ground) triangle mesh? (img ex.) 0 Answers
Trouble with Navmesh Agent and Navmesh Obstacle 0 Answers
Navigation Agent "Clipping" (Going inside) Navmesh Deadzone?... 1 Answer
orienting navmesh to the normal surface of the ground experiences jerky motion 1 Answer