I'm working on an isometric game with Unity and I need to know the centre of the cell in the world coordinates. I'm using the tilemap's GetCellCenterWorld() method, but it gives me back bad results.
Here is what I expect to be the centre of the cell (basically the logical centre), but here is what Unity gives back (the top vertex of the cell?). I believe it has something to do with the sprite's pivot point (now set to its top centre) or the cell anchor in the tilemap's properties (I set it to (1,1)).
Here's the code I use to "select" the tiles:
public class GridSelection : MonoBehaviour
{
public Tilemap tilemap;
public Transform selector;
void Update()
{
Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
worldPos.z = 0;
Vector3Int tilemapPos = tilemap.WorldToCell(worldPos);
selector.position = tilemap.GetCellCenterWorld(tilemapPos);
}
}
How do I get the actual middle point of the cell?