Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Feature Request Add optional offset for individual tiles

Discussion in '2D Experimental Preview' started by DevAndArtist, Jun 29, 2016.

  1. DevAndArtist

    DevAndArtist

    Joined:
    Jun 28, 2016
    Posts:
    7
    The idea is simple:
    • There must be a way for setting an optional offset for individual tiles, which also would be reflected in a tile grid.
    • An optional offset can then be used for fine-tuning the positioning of some tiles.
      • Imagine a rich detailed isometric world like this (source)
      • If we had an optional offset, you could create such a map with ease and only 3 layers:
        • Ground (with raised tiles and `sort order` set to `top right` and tile pivot x-centered and y-top)
        • Buildings (tile pivot x-centered and y-bottom)
        • Objects (some of these might need fine-tuning)
    • I'd wish also the ability to offset multiple tiles at once
    And one extra request which would ease the workflow: add ability to copy a tile map layer with offsetted tiles, but with no tiles applied to them (empty grid with visible moved tiles).

    Being able to fine tune the position like this is less expensive then creating new textures which are slightly offsetted.

    Another visual example (source):
     
    Last edited: Jun 29, 2016
  2. Jay-Pavlina

    Jay-Pavlina

    Joined:
    Feb 19, 2012
    Posts:
    195
    You should be able to offset tiles with the current features. A Matrix4x4 is stored for each cell, and you can modify it with TileMap.SetTransformMatrix. You could create a brush that modifies the transforms of the cells as you paint over them. You can also override the matrix for all instances of a tile by using TileData.flags = TileFlags.OverrideTransform, and then set the matrix you want to use in TileData.transform. These would be set by overriding the BaseTile.GetTileData method.
     
  3. Johaness_Reuben

    Johaness_Reuben

    Joined:
    Jan 27, 2016
    Posts:
    253
    Based on the cool looking example I am curious as to why I would need the offset? What I can see in the image, the floors and walls would make use of the tilemap and rest are unique objects. As an artist, I would layout the ground/floor/walls as tile based, rest I would make as sprites.
    I might be missing the point.
     
  4. DevAndArtist

    DevAndArtist

    Joined:
    Jun 28, 2016
    Posts:
    7

    Check this short video of how an isometric world is created. You can clearly see that offset is needed for fine-tuning the position on some tiles. The tile map layers are great and very powerful, because it supports all these features like ordering and "pseudo" depth.

    This is a custom unity script for creating an isometric game, at 1:50 you'll see how easy it could be to fine-tune positions if you could offset them:


    Here is an even better example for an isometric map from the game called Wakfu (source):


    As you can see the ground has a different (2.5D) height, and your character would be able to walk behind these walls. It would become really complicated to design such a map without the ability to offset individual tiles.

    I'll sum up a little:
    • In such a map the bottom left tile is the tile which is in front of all tiles.
    • The tile right from the bottom left tile has z position = (bottom left tile z) - 1
    • The tiles in the row above of the bottom left tile would be behind all tiles from the bottom row and follow the z ordering I mentioned.
    • That said, you can create such a ground map with a single layer, which is incredible and easier to maintain and fine-tune.
    Again it would be really awesome to have this ability build in and to be able to see this offset reflected by the tile map layer grid, which also could be completely empty.

    Here is another one which disables all the tiles and shows the map without textures (source).




    Tiles might not be perfect made and have a more natural look rather than pixel perfect. But to me an offset is more importantly to reduce different layers to fake the 2.5D depth. I'd love to be able to use a single layer to solve this whole problem.

    Second argument for offsetting tiles I'd say is, to be able to move you character based on the center of each tile, you can also calculate if the character will be able to reach a certain tile based on its fake depth created with an offset.
     
    Last edited: Jun 30, 2016
  5. DevAndArtist

    DevAndArtist

    Joined:
    Jun 28, 2016
    Posts:
    7
    I've got one more question to ask, but first lets pretend we had the ability to offset tiles and we create a single layer with fake 2.5D depth/height. Now we add our character to the project. When our character will move around he should follow the z ordering rules of the tiles and appear behind certain tiles whenever he's on a higher y position but a lower tile is offsetted on the y-axis to appear higher. (Like the red tile from the last image I posted at the top right position. It appears behind the tile underneath it which also is offsetted.)

    * Will I be able to achieve this for my character OR am I forced to create a different layer for each ground row?

    Here is a great image of different isometric tiles (source):

    With the ability of custom pivot and tile offset you can use tiles from (9) and (13) on a single layer. If you had no offset you'd need to create more versions of these tiles for extra layers, because layers only overlap but not intersect with each other.
     
    Last edited: Jun 30, 2016
  6. Johaness_Reuben

    Johaness_Reuben

    Joined:
    Jan 27, 2016
    Posts:
    253
    @DevAndArtist:
    Thanks for all that good info. I was doing some research on it yesterday. I more used to different workflows, which use many layers and "workarounds" and custom cases. Even where character movements were treated separately I understand better now what you mean.
    Currently looking at the different workflows to see how and where we can provide improvements and flexibility.

    First thing I would look at is what Jay suggested.
     
  7. DevAndArtist

    DevAndArtist

    Joined:
    Jun 28, 2016
    Posts:
    7
    @Johaness_Reuben:
    Thank you for investigating on that problem. :)

    I've created a little video how offsetting tiles might be reflected on a grid layer (even if its empty).