2D Tilemap is a powerful tool that provides you with a simple way to create
2-dimentional environments, based on the grid layout.
In 2018.3, Unity is adding support
for a new type of grid
which will allow you to make isometric levels
the like of which can be seen in:
Pillars of Eternity
The Banner Saga
Shadowrun, and many more.
In addition, since 2018.2,
Unity also support hexagonal grids
which are commonly encountered in strategies,
and other turn-based games.
In this video, you will learn how to setup
the new isometric and hexagonal tilemaps,
as well as all the essential workflows
that will help you get started.
Be sure to check out the demo project in the video description,
if you'd like to use the demonstrated assets yourself
Tilemap has been a part of the editor since 2017.2
and doesn't require any additional package downloads to work.
To use the new tilemap grids,
you just need to make sure
that you are on the right version of Unity.
You are going to need 2018.2 or higher for hex tilemaps.
And 2018.3 onwards for isometric。
Tilemap consists of several components working together.
First we have a grid GameObject.
This create your chosen grid type in the scene
and gives you further options to customize its parameters,
such as the cell size.
We can then attach one or more tilemap game objects to our grid.
Once we have a tilemap,
we need to create a palette which will hold our tile assets.
You can access the tile palette menu
from Window -> 2D -> Tile Palette
From here, you can create new palettes
corresponding to each of the different grid types.
You can add tiles to a palette
by simply dragging the sprites from the Project Window onto the palette.
Once you have a tile ready,
select it with the brush tool,
and choose the tile map game object you wish to paint on.
If you go back to the scene view,
you will now be able to start painting with your tile.
Your isometric or hexagonal grid can hold more than one tilemap.
You can use this to place some decorative objects on top of your tiles.
Or to create elevation levels and buildings.
You can change the sort order of the new tilemap,
so that it renders on top of the previous one.
You can also change the tile anchor setting,
to place your tiles on the higher point relative to the grid.
If you're using isometric tiles, you could also use a Z as Y tilemap,
and create elevation by simply changing the Z position of the tiles.
There's an example available on the 2d tech demos repository,
where you will find a scripted brush
that lets you adjust the set value dynamically as you paint.
You can find a link to the repository down in the video description.
At some point you will likely want to add collision to your tiles.
For this purpose you can use a Tilemap Collider 2D component,
which will automatically generate collision shapes for each individual tile.
In the tile asset settings,
you can adjust the type of physics shape each tile has.
You can change the collider to be either sprite based or grid based.
If your tile has a grid Collider,
its collision shape will match exactly with the shape of the grid cell
it is attached to
With a Sprite Collider you can add a custom physics shape to your tiles
by using the sprite editor.
Once you have a tilemap collider,
you might wish to merge the individual shapes into one
by using a Composite Collider 2D
As you can see tilemap offers a simple and fast solution to creating physics shapes.
If you have characters in your top-down game,
you will most likely want them to be able to
go behind and in front of objects on your level.
In this case
be sure to set the sort mode on the tilemap with your objects
to "Individual".
Now if your character sort order is the same as that of the tile map
it will appear to go behind and in front of the tiles on that tile map
You could adjust the sort order dynamically
to move the character to higher or lower elevation levels
If you want to speed up your world building with tilemap,
you can use Rule Tiles to extend your tile presets.
For example, you could make it so that when you're painting a certain type of terrain,
the correctly oriented tiles are chosen automatically for you.
You could also randomize different variations of the same tile.
Rule Tiles can save you a great amount of time in creating complex 2d environments.
The new hexagonal and isometric Rule Tiles are now available
on the 2d tech demos repository.
So feel free to go ahead and check them out for yourself.
Of course you're also able to extend tilemap with your own tile types.
Take a look at the featured documentation to learn more
Hopefully, this video has taught you some useful workflows for the new types of tilemap.
There's a lot more you can do,
but these basics will be a good starting point
if you want to try them out yourself.
You may also want to check out some of our tilemap blog posts,
including the one on procedural generation by Ethan Bruins.
The assets used in this video are available down in the link below
and are free for you to use as you wish.
As always, we're looking forward to seeing all the awesome projects
that you will create using unity's new tools.
Please share your creations and feedback on the unity forum