# Problem with grid generation in Unity 5.1

Using Unity 5.1 and was following a tutorial for generating a grid for a Minesweeper-style game. Link to the tutorial for reference: http://gamedevelopment.tutsplus.com/tutorials/build-a-grid-based-puzzle-game-like-minesweeper-in-unity-setup--cms-21361

Tutorial is Unity 4, but I don't think it should matter.

Here's my code:

public GameObject tilePrefab;
public int numOfTiles = 10;
public float distanceBetweenTiles = 1f;

void Start () {
CreateTiles();
}

void CreateTiles () {
float xOffset = 0f;

for (int tilesCreated = 0; tilesCreated < numOfTiles; tilesCreated++) {
Vector3 positionVar = new Vector3(transform.position.x + xOffset, transform.position.y, transform.position.z);
xOffset += distanceBetweenTiles;
Instantiate(tilePrefab, positionVar, transform.rotation);
}
}


Essentially, the problem is that when I coded the spacing algorithm, Unity decided to ignore the spacing of 1f, but instead do 10,000. No matter the number I substitute for "distanceBetweenTiles", Unity spaces the cubes by 10,000 points. I'm assuming it has to do with how Unity is handling the float numbers, but I'm not quite sure, considering the number I substitute doesn't seem to matter. I've included a screenshot of Unity running the script and the inspector view of the giant X position. Thanks so much in advance]1

• You can remove the public modifier if you don't need to change it in the inspector and you want to avoid these kinds of issues in the future. – MichaelHouse Sep 5 '15 at 3:16