This video covers first how to create a TileSet, then how to use the TileSet to create maps using the Godot 3 TileMap object. We also look at the code required to select an individual tile in a tilemap as well as how to dynamically add news tiles to your map. The tutorial also briefly looks at how to set collisions up for use with the Godot physics engine.
Assets and Code Samples
The tiles used in this tutorial are available for download from here. We used the file tileset.png from the Tiny RPG collection. Feel free to substitute any tile map you might have, but be sure to update the tile size in both the tileset and tile map cell properties.
The following example code was attached to the root Node instead of to the tile map directly like it was in the video.
# When the user clicks the mouse, conver the mouse coordinate to map coordinates
# then get the cell at that location. If there is a tile there, simply print
# the name of the tile to the console, if there is no tile there, draw the first
# tile from the tile set to this location
var mousePos = get_viewport().get_mouse_position()
var loc = $TileMap.world_to_map(mousePos)
var cell = $TileMap.get_cell(loc.x, loc.y)
if(cell != -1):