If I understand what your after, then I think some code I was playing within a previous project might help. I’ll just paste the relevant section verbatim, with some extra comments. You probably won’t find it useful as is, but it should show you how to go about using maps, tileinfo etc
// Create the tilemap component for this actor at construct time
_tileMap = CreateDefaultSubobject<UPaperTileMapComponent>(TEXT("TileMap"));
_tileMap->AttachToComponent(scene, FAttachmentTransformRules::KeepRelativeTransform);
// Load existing map and tileset assets. Tilemap itself is empty, but I had configured it with 3 layers.
// You can add layers in code, but I found it easier to set up things like tint, transparency etc in the Editor
UPaperTileMap* map = Cast<UPaperTileMap>(StaticLoadObject(UPaperTileMap::StaticClass(), this, TEXT("PaperTileMap'/Game/Assets/Map/MainTileMap.MainTileMap'")));
UPaperTileSet* set = Cast<UPaperTileSet>(StaticLoadObject(UPaperTileSet::StaticClass(), this, TEXT("PaperTileSet'/Game/Assets/Map/MainTileset.MainTileset'")));
// In the Editor, I had used the Userdata for each tile in the tileset
// to give it a human readable name (rather than just using the numeric ID)
// Here I loop through each tile in the tileset, and create a TMap (_mapTiles) associating
// the Userdata name with a FPaperTileInfo struct referencing that Tile ID.
// This makes it easy to refer to each tile later in the code
for (int i = 0; i < set->GetTileCount(); i++)
{
if (set->GetTileUserData(i) != NAME_None)
{
FPaperTileInfo a;
a.TileSet = set;
a.PackedTileIndex = i;
_mapTiles.Add(set->GetTileUserData(i).ToString(), a);
}
}
// Now do a similar thing for layers, using a TMap so I can easily get
// layer ID from the name I gave the tilemap layer in the Editor.
for (UPaperTileLayer* layer : map->TileLayers)
{
_mapLayers.Add(layer->LayerName.ToString(), layer->GetLayerIndex());
}
// Set the actor's TileMap component to use this map
_tileMap->SetTileMap(map);
// Required to allow using SetTile()
_tileMap->MakeTileMapEditable();
// Set the required size, then loop through every tile in the map
// and set the default value. The "Terrain" layer are all set
// to tiles whose Userdata is "GrassA", and the Visibility layer
// is set to "FogFull" tiles
_tileMap->ResizeMap(MapWidth, MapHeight);
for (int x = 0; x < MapWidth; x++)
for (int y = 0; y < MapHeight; y++)
{
_tileMap->SetTile(x, y, _mapLayers"Terrain"], _mapTiles"GrassA"]);
_tileMap->SetTile(x, y, _mapLayers"Visibility"], _mapTiles"FogFull"]);
}
So in short, a FPaperTileInfo struct must be told which tileset asset it refers to, and then set the PackedTileIndex to reference a specific tile ID in that set. Then you can pass that TileInfo, along with the layer ID, to map SetTile()
I hope that helps a bit
However, a big, big caveat I found and could not solve at the time, is that I could find no way to re-build the collision info after creating/altering the TileMap in code. TileMapComponent has a RebuildCollision() function, but that never worked for me. Perhaps it’s changed in 4.13, or if you find a way to do it I’d love to know!
That said, depending on the style of game, you may not even need to have collision shapes defined on each tile anyway.