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

Instantiating in a for loop is causing an infinite loop?

$
0
0
ok, so I have been trying to figure this out for two days now. The for loop in my StartingFloor() function works fine if I comment out the instantiate like, but otherwise, it crashes. var Tile : GameObject; var gameStart = true; function StartingFloor(FloorTile : GameObject) { var tilesInRow = 7; var rowsInColumn = 7; var HALF_ROW = 3; var TILE_SIZE = 0.24; var tileY = 0; for(var tileX = 0; tileX < tilesInRow; tileX++) { var tilePosition = Vector3(-1 * (HALF_ROW * TILE_SIZE) + (tileX * TILE_SIZE), tileY, 0); Instantiate(FloorTile, tilePosition, FloorTile.transform.rotation); if((tileX - (tilesInRow - 1)) % tilesInRow == 0) { tileY += 1; } yield WaitForSeconds(3); Debug.Log(tileX); } } function Start () { StartingFloor(Tile); }

Viewing all articles
Browse latest Browse all 184

Trending Articles



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