Tiled Editor map and tileset integration with Godot 3.2

Hello,

TLDR:

Should I work on the Godot Import Plugin from Tiled or make a custom Tiled Export Plugin for .scene and .tres files (.tmx and .tsx accordingly)?

This question arose because the existing plugin has performance issues and crashes the editor.

For more details about the situation please read below till the end.


I’ve used Tiled through the years for small web games mainly with Phaser.

Over the last 2-3 months I’ve been playing with and loving Godot 3 so instinctively I went for Tiled as a tilemap and a level editor.

An issue came up with importing the .tmx and .tsx files in the Godot editor.

The existing plugin for TMX import to Godot is: https://github.com/vnen/godot-tiled-importer.

It works but…

  1. It’s made some time ago and after import, it creates tilesets with Single Tiles - this results in tilesets with 500+ tiles for a regular 16x16px sprite sheet (704x196 sized image) which makes the Godot editor crash on import.

This can be avoided by setting the project settings in Godot:

Message Queue -> Max Size Kb-> 102400 (or other big value by default it’s 1024)

But we all know that this is a workaround and not a solution.

  1. The existing plugin parses the .tmx / .tsx files and creates Scene files and Tilemap nodes in Single Tile mode. At some point during the Godot Engine development, a new Tileset mode was added - Atlas mode which has far better performance.

At the moment, if you try to import a tilemap through the plugin with a size bigger than 500 x 500 tiles, the Godot editor crashes with no error or log message…I suppose it just runs out of memory.

I’ve made some performance tests with a Tilemap made in Godot Engine with Atlas mode and a map of 2300x1000 tiles and it doesn’t even sweat running on 60fps. The same experiment with the imported .tmx file and Single Tiles dropped the frame rate to 20fps with a map of 812x215 tiles (both maps are 16x16px tiles) so surprise surprise - Atlas is faster.

The Tiled Editor does a far better job of drawing, layering and editing maps. Maybe in the future Godot will have all the cool features built-in but for the time being it doesn’t. Building complex tilemaps with several layers is cumbersome.

So to fix my problem I see two paths:

  1. I can try to edit the Godot import plugin and make the changes to import the .tmx file with the new Atlas mode.

  2. To write an export plugin using the new JS API for Tiled 3.2 which will export the tilesets to .tres files which Godot uses, and the .tmx to .scene files.

Both Godot files are text-based formats. More info about the .tscn: https://docs.godotengine.org/en/3.2/development/file_formats/tscn.html

So as I already looked through the Godot plugin code and all the XML equilibristics (500+ rows of code) I’m more inclined to make a Tiled export plugin since it looks simpler and less error-prone.

As I see the first things should be:

Exporting a tileset as .tres with all the tiles with their position and collision and reference to the image sprite sheet.

Exporting a .scene file with Tilemap node and the Tilemap position of each tile and its collision polygon if such a polygon exists.

For each layer form Tiled, a new sub-scene will be created

Other features may come later one by one once the basics are working.

Features like custom properties, navigation maps and so on.

This long post was born after more than a month of struggle with Godot TileMaps.

This topic is published as-is in the Godot Forum/Reddit as well because I will really appreciate any recommendations regarding the process of creating 2D maps and levels, and the general support of both Godot and Tiled communities.

1 Like

Hello @Mihail_Ilinov! Thanks for bringing up this topic here. I had no idea the existing Godot importer was suffering such performance issues and it’s great to hear you want to do something about it!

Personally, I think it’s preferable to write an exporter for Godot than to have an importer plugin. Whether to write this exporter in C++ or JavaScript would depend on what you feel most comfortable with. Either way I’d be there to help you with the project and I would be eager to ship a good working Godot extension along with Tiled.

Of course you may want to consider the resulting workflow differences between an importer and an exporter. How many steps would be required to see a change in the game after making it in Tiled?

In any case, please keep us updated and let me know if I can help with anything!