How to create several prefabs witch do not touch each other
Hi, I'd like to add prefabs in a terrain by script in a FOR loop like this :
for (var i : int = 0; i < 50; i++) {
var posX : int = Random.value * 500;
var posZ : int = Random.value * 500;
var rotY : int = Random.value * 360;
myPrefab[i] = Instantiate (Resources.Load("prefab"), Vector3 (posX, 0, posZ), Quaternion.Euler (0, rotY, 0));
}
How to add prefabs avoiding they touch each other ? Is it possible to call OnTriggerEnter or OnCollisionEnter in the Update function ?
Comment