Unity 2020 WorldToCell for Hexagonal Tilemap

Hello everyone,

I’m using unity 2020 and working on a 2D project. I would like to know the Tile coordinate where my mouse is over.

To do so, I use:

Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

To get the real world mouse Position. Then,

grid.WorldToCell(mouseWorldPos) 

or

tilemap.WorldToCell(mouseWorldPos)

To Get the cell coordinate.

But this doesn’t work with hexagonal Tilemap.

I tried this solution : How to convert game object world position to hex grid cell coordinates? - Questions & Answers - Unity Discussions but the results are incorrect too.

For information, I set my tiles size as following X=2.598 Y=3.

Can Someone help me please ?

My Bad !

The grid.WorldToCell(mouseWorldPos) method works well. Even for orthogonnal Grids.

The problem was that I changed the Grid type and the tilemap keeps the anchors at 0.5. For an hexagonal tilemap, anchors are at 0.