2
\$\begingroup\$

enter image description here

As you can see the image my enemy (when following my player), penetrate each other. How can i avoid it? I am using NevMeshagent to follow the player.

void Update () {
    currentNavMeshAgent.destination = player.transform.position;
}

I have added a Rigidbody and a Collider to my enemy object but they are still penetrating each other

\$\endgroup\$
2
\$\begingroup\$

To avoid penetration, increase each NavMeshAgent's radius so it's equal to or larger than your agent's collider.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

There are several solutions to this, but, based on the image you posted i assume that your "enemies" are zombies, so, they don't have or need to "think" by themselves, right?

In this particular case I'd bet for a swarm approach, by doing this instead of managing each of the zeds one by one, you can have a logic 2D Matrix and check where your monsters are before moving, by A* or any other pathfinding approach you want to use. By doing this, you would be able to skip AABB collision checks between your enemy entities, boosting your performance and knowing that your main enemy puppet master wont let them collide.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ NevMesh based on A* also. I guess \$\endgroup\$ – Muhammad Faizan Khan May 11 '17 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.