Quantcast
Channel: Questions in topic: "random spawn"
Viewing all articles
Browse latest Browse all 125

Instantiating objects at random positions with a certain distance between each other?

$
0
0
I have an Empty gameObject that creates 20 objects at the start of the game. var houses:Array = new Array(); var hs:Transform; function Start () { for(var a:int = 0; a < 20; a++) { ex = Random.Range(-200, 201); zee = Random.Range(-200, 201); newPos = Vector3(ex, 400, zee); newhs = Instantiate(hs, newPos, transform.rotation); houses.Push(newhs); } } How can I make sure that all of the objects are a certain distance from each other? I know it probably involves a for-loop inside the initial for-loop to check the distances. Anyone have an example script? Or an idea of what i can do? Thanks

Viewing all articles
Browse latest Browse all 125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>