- Home /
Unity3d keeping multiple gameobjects a mimimum distance between each other c#
I have multiple enemies that move toward the player. I am trying to stop them from merging into each other, i.e maintain some type of minimum distance between each other. What I'm trying is this (from unity3d forums):
enemy1.transform.position = (enemy1.transform.position - enemy2.transform.position).normalized * distance + enemy2.transform.position;
However, when I have >= 3 enemies they still seem to bunch up even when I apply this to every enemy combination.
I need a better method as this one does not work and does not scale.
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
How can I target/attack all gameobjects in a certain area? 1 Answer
How can I make a GameObject move from one side to the other 0 Answers
Render Extremely Far off Objects 1 Answer
multiple enemies does nt work with this script but a a single enemy works..Please help 0 Answers