Question by
mcmikecreations · Mar 29, 2016 at 01:00 PM ·
movegenerationoverlap
Move overlaping objects
I didn't find anything that could help me, so I'm writing here. Here's my code:
for (int i = 1; i < rooms + 1; i++)
{
Vector2 pos1 = Random.insideUnitCircle;
pos1 = new Vector2(pos1.x * 50, pos1.y * 50);
GameObject room = GameObject.Instantiate(roomO,new Vector3(pos1.x,0.5f,pos1.y),transform.rotation) as GameObject;
room.name = i.ToString();
int _long = Random.Range(11,31);
int _wide = Random.Range(11,31);
room.transform.localScale = new Vector3(_long, 1, _wide);
}
As you can see, I create a few cubes (roomO) with different width and height, but the problem is: they are overlapping. I need to somehow spread them so they stop colliding. I tried doing it with a collider, but it is extremely buggy. Is there a proper way to separate objects with a collider or using flock behaviours?
Comment
Your answer
Follow this Question
Related Questions
Randomly generated content? 1 Answer
Generate Random Numbers a Distance Apart From Each Other 1 Answer
How can I recalculate mesh collider to fit mesh? 0 Answers
Creating a grid on top of a terrain 0 Answers
Help! Moved SDK folder from C to D 0 Answers