Search Unity

Tilemap Palette Doesn't Work Well With Non-Center Pivot Sprites

Discussion in '2D' started by WilsonCWong, Feb 7, 2018.

  1. WilsonCWong

    WilsonCWong

    Joined:
    Mar 20, 2013
    Posts:
    35
    This problem has been reported before.

    Basically, if you're using sprites that have any pivot beside "center", it'll end up looking like this: upload_2018-2-6_22-45-48.png

    In my case, the sprites have their pivot at the top-right. The alignment issues are fixable in the tilemap grid by setting the tile anchor (X = 1.0 Y = 1.0 in my case) on the Tilemap component, but there isn't a setting like that for the palette. So I need to select the grid cell top-right of the tile to actually paint it, like so:

    upload_2018-2-6_22-47-59.png

    Are there plans to fix this?
     
    CheekySparrow78 and mindcrank like this.
  2. dakasha

    dakasha

    Joined:
    Nov 20, 2010
    Posts:
    29
    I literally cant believe that S*** like this is just ignored by the devs for months/years on end
     
    CheekySparrow78 likes this.
  3. CheekySparrow78

    CheekySparrow78

    Joined:
    Feb 9, 2019
    Posts:
    15
    Just encountered this as well. It seems ANY top down tile based RPG would be affected by this. Come on, really?
     
    PostleService likes this.
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The Tile Palette has a Tile Anchor property in its Tilemap.

    If you select the Tile Palette Prefab and access the Tilemap component in it, you can change the Tile Anchor property such that it fits your Tile's pivots.
     
  5. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Ah, it was enough to fix the offset on tiles in the Scene itself, but it didn't fix the visible offset in the Tile Palette window's Tile editor itself.

    2020-02-28 Tilemap Anchor fixes offset locally but not in Tile Palette editor itself.png

    So I'll stick to Center pivot for the moment.
     
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Have you updated the Tile Anchor property for your Tile Palette asset? You will need to do this to match the changes you have made for the Tilemap in the Scene.
     
  7. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Thanks, it worked. But I didn't find it at first, so I'll add screenshots so other users can find where the settings are:

    Select the Tile Palette prefab asset you are using in the Project window, then click Open Prefab in the inspector.

    upload_2020-3-17_19-49-50.png

    In the Prefab view, select Layer1 (or if you renamed it, the 1st child with a Tilemap component). Actually I think there should be only one layer as the palette is a special tilemap, only meant to be use to paint scene tilemaps.

    upload_2020-3-17_19-51-34.png

    Then on the Tilemap component, set Tile Anchor to whatever matches your new sprite anchor (e.g. (0, 0) for Bottom-Left):

    upload_2020-3-17_19-52-25.png

    Unity considers the tile palette as a tilemap itself, which references Tile assets, which can be reused multiple times. This is convenient to prepare common patterns like a small lake made or water border and center tiles, or having a row of favorite tiles. So this last operation is really about making that special tilemap align correctly in the Tile Palette editor window.

    If like me, you're an former user of tk2d tilemap (where palettes are very different data structures dedicated to filling tilemaps), it's useful to understand this particularity.

    Unfortunately, there is no way to find which Tile Palettes have been used for each scene tilemap, as any palette can be used on any tilemap. Just repeat this operation for any Tilemap and any Palette where tiles should be anchored differently.
     
    Le_Jo likes this.
  8. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Actually visually things are correct, but when using Collider Type: Grid on my tiles, colliders are off.

    upload_2020-3-17_20-14-45.png

    To fix this, I must select any colliding tile and change Collider Type to Sprite.

    upload_2020-3-17_20-15-41.png

    This will effectively use the offset sprite collider:

    upload_2020-3-17_20-16-14.png

    But it's weird that the Grid setting doesn't also offset the square collider. Is it by design?
     
  9. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Yes, this is by design. When using the Grid Collider Type with a TilemapCollider2D, the center Grid Cell will be anchored based on the Tilemap's Tile Anchor (which is 0,0,0 from your above example), resulting in the collider shapes you see. This is mainly for situations where the usage of the Grid is focused on the Grid lines and intersection points (eg. a Go board) rather than the Grid cell (eg. a Chess board).

    Using the Sprite Collider Type would be suitable when you want the collider shapes to match up with the visuals of your Sprites.
     
  10. pzoghbi

    pzoghbi

    Joined:
    Oct 8, 2019
    Posts:
    24
    Hi, thanks for all the previous solutions. However keen, that didn't help me solve the issue.

    I would like to re-open this thread by saying that it won't sort properly for me.

    I'm using tilemap grids, my object has its sorting point set to pivot. Each of the fence tiles pivot points has been set to the bottom of the fence..

    I am also using rule tile.

    How to we y-sort the tiles then?
    upload_2020-7-26_17-33-32.png
     
    Last edited: Jul 26, 2020
  11. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
  12. g-alien

    g-alien

    Joined:
    Jul 17, 2023
    Posts:
    3