- Home /
Question by
erikdewhurst · Oct 28, 2019 at 02:14 AM ·
tilemapgrid2d spritestile
TileMap.GetTile not working as expected
I wrote the following code on a TileMap object with the intention of getting the TileBase Object from position "worldPosition". Instead, I get the tile at the top right position of the entire tilemap.
GridLayout gridLayout = transform.GetComponent<Tilemap>();
Tilemap tileMap = GetComponentInParent<GridLayout>();
worldPosition = Vector3(0,0,0);
positionOfTile = gridLayout.WorldToCell(worldPosition); // Get Affected Tile Position
tileToDamage = tileMap.GetTile(positionOfTile); // Get Affected Tile
Assuming there is a tile in the TileMap at position 0,0,0 should I expect this code to get me that TileBase object? Or am I missing something obvious?
Comment