- Home /
 
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               JetStreamSham · Jul 16, 2015 at 03:00 PM · 
                tilemaptiletiles  
              
 
              Tilemap has gap between tiles, how do I get rid if it.
I've created a script that creates a bunch of tiles, but all of the tiles have a gap between them, what is a good way to get rid of the gaps.
Here's a picture: 
here's the code used to generate the tiles
 using UnityEngine;
 using System.Collections;
 
 public class TileLoader : MonoBehaviour{
     public GameObject prefabTile;
     public int TileWidth = 16;
     public int TileHeight = 16;
     public int size = 3;
     
 
     // Use this for initialization
     void Start () {
     loadTile();
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     void loadTile()
     {
         for(int i=0; i < TileWidth; i++)
             for(int j=0; j<TileHeight;j++)
         {
             GameObject tile = Instantiate(prefabTile, new Vector3(i*size,0,j*size),Quaternion.Euler(0,0,0)) as GameObject;
             tile.transform.parent = transform;
         }    
     }
     
 }
 
               
                 
                tiles-with-gaps.jpg 
                (51.5 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Graham-Dunnett · Jul 16, 2015 at 03:01 PM
Come now. You have a variable called size which is set to 3. This is used to separate the blocks. Look up the size of the tile. My suspicion is that it's smaller than 3 units. 
Upon closer inspection the size was not 3. Now, I feel silly. Thank you.
Your answer