• 2D
  • Can it load Tiled map at runtime?

While I can't use Godot yet (lack of C# export modules and my undying hatred for any python-like language, also let's face it - you can't use visual scripting for anything even relatively complex without it turning into a literal spaghetti code with meatballs of nodes), I plan to move my 2d game project to it once C# is fully supported.

But I need to know one thing: Is there a module, either community or built-in to load Tiled maps at runtime? I want the game to be fully modable so I want an easy way for users to build their own maps without downloading entire Godot or open-sourcing my game. As hassle-free as posible to use and able to load custom tileset as well. Does anyone know of anything like that?

Maybe? There is a tiled plugin. Never used it myself, though I hear it's quite good :smiley: . It may be able to load at runtime. (Since it's open source, in theory you can add runtime loading if it's missing)

The author says it's "out of scope" and I really don't know enough about Godot to add it myself. I'm looking for a "fier and forget" solution.

16 days later

You can load everything you want at runtime. I'm currently developing a dungeon crawler with random maps and it's rather easy (excluding the random generator of course :) ). You need to use at minimum two following methods from TileMap:

set_tileset set_cell Let's say that map is your TileMap node. Now you can: map.set_tileset(load("res://tilesets/dungeon.tres")) This will setup a tileset for tilemap. You can have several and set whatever you want. Now let's say that raw_map is a two-dimensional array loaded from text file (you can invent whatever format you want for this - json, binary etc.). Every value in the array is a tileset index (0 is first tile image). for y in range (0, raw_map.size):

for x in range (0, raw_map[y].size):

map.set_cell(x, y, raw_map[y][x]) And you have it - you have loaded a TileMap from file. Of course this code can be also used to generate map by code, some parts of the tilemap you can load and some you can generate etc. Since tileset is also an engine object you could also modify it at runtime (check docs for available methods), however I think it's much better to just make a tileset (for example lava_dungeon.tres) and use it as a resource, without touching it from the code.

Remember that in one tileset index 0 may be a wall and in another tileset it may be a floor! If you load from file it won't be usually a problem, but if you generate random maps then you will have to follow a convention or plan for differently constructed tilesets.