title: Why Unity hasTile display False?
body: <p>Im created a 3d tilemap using free asset models as shown below:</p>
  <p><a href="https://i.stack.imgur.com/EUt32.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUt32.png" alt="enter image description here" /></a></p>
  <p>and here is the code where I am trying to get its position:</p>
  <pre><code>// Update is called once per frame
  void Update()
  {
     if(Input.GetMouseButtonDown(0))
     {
         //read in another post that changing to vector 2 will help
         Vector2 mousePosition = (Vector2)Input.mousePosition;
         Ray ray = cameraMain.ScreenPointToRay(mousePosition);
         //performing raycast
         if(Physics.Raycast(ray, out RaycastHit hitInfo))
         {
             //checking if hit the collider of gameobject and checking if the renderer is not null
             if(hitInfo.collider.gameObject.GetComponent&lt;Target&gt;() != null)
             {
                 Vector3 rayPosition = hitInfo.point;
                  //Vector3Int posInt = grid.WorldToCell(hitInfo.point);
                  Vector3Int posInt = grid.LocalToCell(rayPosition);
                  //Vector3Int posInt2 = tilemap.WorldToCell(mp);
  
                  //Shows the cell reference for the grid
                  Debug.Log(posInt);
  
                  // Shows the name of the tile at the specified coordinates
                  Debug.Log(tilemap.HasTile(posInt));
                  //Debug.Log(tilemap.GetTile(posInt).name);
                  
              }
         }
     }
  }
  </code></pre>
  <p>and this is the result:
  <a href="https://i.stack.imgur.com/bn8lg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bn8lg.png" alt="enter image description here" /></a></p>
  <p>I want to use getTile, but it keeps saying object reference not set to the instance of the object, so I used hasTile to check if the tile is there. For some reason it is displaying false. Can someone tell me what is wrong?</p>