Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

Nested loop queston

$
0
0
I'm trying to create a 5 x 5 grid of spheres using a nested loop. it looks like this: public GameObject ball: for (int y = 0; y < 5; y++){ for ( int x = 0; x < 5; x++){ GameObject spheres = GameObject.Instantiate(ball); Vector3 xPos = new Vector3((x * 3), 0, 0); spheres.transform.position = xPos; } Vector3 yPos = new Vector3(0, (y *3), 0); transform.position = yPos; } I'm getting the correct number of spheres and the x position offset is working but the Y position is not. Any ideas??? ..or is there a better way to do this? Thanks, Jeff

Viewing all articles
Browse latest Browse all 184

Trending Articles



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