Tile sprite offset from isometric grid

I’m currently having an issue where my sprite is offset from the grid, and I believe it’s because of the unused space at the top of the image.

The sprite is 256x256, but it is isometric so this floor tile is really 256x128. The top half of the image is transparent, and I believe that’s why the grid does not line up with my image.

Does anyone know of a way to fix that? I’ve tried messing with different PPU, googling, and browsing random parts of Unity but I’ve had no success.

Tilemap:
Imgur

Sprite:
Imgur

Sprite Editor:
Imgur

Inspector:
Imgur

Thank you very much!

Sprite Editor:
Change your pivot to custom, pivot unit mode to pixels and custom pivot Y to 64.

That was so simple, thank you very much!! Looks exactly like it should now I appreciate it :slight_smile:

I came across this thread and thought it might be better if I jump in here rather than create a new one.

Is there anything wrong with the tile anchor value being different from the sprite pivot?

I have perfectly set up isometric 64x64 tiles. I have done the correct math for the tile cap x and y value to be properly setup when creating a palette. I have setup the proper graphic project settings.

My tile palette just does not match up it’s grid with my tiles and visually it drives me bonkers. So, I adjusted the pivot of my tile sprite to custom, x:0 and y:0.25. No idea why I had to use that y value but anyhow. Now the tiles align with the palette grid visually. Is there anything wrong with me setting the pivot that way?

So then, I had to fix my tiles not aligning with my tile map grid. I changed my x and y anchor values to x:0.5 and y:0.5 and they align properly with the grid now.

My question would be is there anything wrong with what I just did? Am I going to find out I have made a terrible decision in how I have set this up? As a side note, I will be wanting to add component colliders to this tile map as well if that’s a consideration around sprite pivots.

I saw a similar thread here:
https://gamedev.stackexchange.com/questions/160502/tile-palette-off-centered

and made note of this in that thread:
2.) In the inspector, after selecting the sprite that I wanted fixed properly on the tile palette, I changed the sprite's pivot from "bottom left" to "center".

and then someone responded with:
I think this is a suboptimal workaround, because the pivot location of tiles should be determined by considerations about the game mechanics, not based on a UI workaround. I hope this gets fixed in a future version of Unity.

Which makes me really question messing with pivots at all to make the grid align properly in the tile palette. Anyone have some thoughts on this?

I use an isometric palette and do not have this problem. Are you sure your Tile Palette is set up correctly? Revert the pivot for the sprite, create a new palette, pay attention to the parameters the palette gives you upon creation, and drag a single tile in. Where does it end up? Can you adjust solely the pivot to center it properly? If not, it may help to see a screenshot.

In isometric, I use the pivot to adjust tall objects so that their base (e.g. bottom trunk of tree) is square in the middle of the tile. This should match for both the palette and scene. A pivot like this ensures that characters sort properly against a tree when they walk around.

Doing something fancy with the anchors and compensating with the pivot… it’s hard for me to comment on whether this is dangerous since it’s unnecessary for my case so I don’t know how it might affect tilemap API methods or physics.

Ok I think I am much closer. I am now able to use my sprite pivot as center, center.

I now have the tile anchor on the tile map as x:1, y:1, z:0.

*** What wasn’t immediately obvious or mentioned almost anywhere is that you can double click the tile palette prefab and edit the anchor there as well to adjust how it aligns to the grid in the tile palette (not the tile map). ***

I have set those tile palette anchors as x:1, y:1, z:0 and now it looks like my tiles are aligning to the palette grid.

Now my tiles are aligned to the grid in the tile map and in the tile palette using 1,1,0.

BTW, I am using an isometric grid with Z as Y.

Does this revised setup now sound correct for using a Z as Y grid? Should my anchors actually be 0,0,0?

Another (not immediately obvious) discovery that isn’t mentioned clearly (at least to me).

You need to adjust your z value for the custom axis in the project settings → graphics → Camera Settings to accommodate for proper heights.

First, take the Y dimension of your grid. Multiply this value by negative 0.5, and subtract an additional 0.01 from it.

Following this formula, a grid that has the dimensions (1, 0.5, 1) will give us a Z sorting value of -0.26 (negative point twenty-six). At this axis sort value, any (1, 0.5, 1) grid will have its tiles sorting correctly.

They kind of just breeze over this everywhere else. When they say ‘grid dimensions’ they actually mean ‘grid cell size’. I hope this helps someone else with Z as Y isometric grids.