vnen / godot-tiled-importer

Plugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets
MIT License
830 stars 86 forks source link
gdscript godot godot-engine tiled tilemap tilesets

Tiled Map Importer

This is a plugin for Godot Engine to import TileMaps and TileSets from the Tiled Map Editor.

Note: This is compatible only with Godot 3.0 or later. For Godot 2.x, use the 1.x branch.

ko-fi If you like what I do, please consider buying me a coffee on Ko-fi.

The last 2 images are from the game Indirection on Steam. You can check it out here!

Installation

Simply download it from Godot Asset Library: https://godotengine.org/asset-library/asset/158.

Alternatively, download or clone this repository and copy the contents of the addons folder to your own project's addons folder.

Then enable the plugin on the Project Settings.

Features

Usage (once the plugin is enabled)

  1. Place your maps inside your project.
  2. Watch Godot import it automatically.

The map file can be used as if it were a scene, but you can not edit it in Godot. If you need to make changes, create an inherited scene or instance the map in another scene.

Whenever you make a change to the map in Tiled, Godot will reimport the scene and update it in the editor if it's open.

If the file can't be imported, an error message will be generated in the output. Please check the output if you are having an issue.

Note that if you are using external tilesets, they will also be imported, which may increase the final export size of your project. To mitigate that, you can exclude those files from the export or put them in a folder alongside a .gdignore file so they are not even imported.

Note: If you have other .json files in your project, this plugin will try to import them and fail. There's an option in the Project Settings to disable the JSON format and avoid this. If you need to use JSON format for Tiled files, consider putting the non-Tiled JSON files in a folder alongside a .gdignore file so Godot won't try to import them.

Find more useage information on the Wiki.

Caveats on Tiled maps

Import system caveats

Options (Maps and TileSets)

There are two import presets: Default and Pixel Art. The difference is that the Pixel Art preset don't use any flag for the texture, disabling filter, mipmaps, and repeat.

Because it overrides the image flags, it also embed internal images by default, otherwise it won't make a difference. If you want to avoid that, use the Default preset and import your images without flags.

Note that you can set a different default preset on Godot.

In the Project Settings, there's a Tiled Importer section with settings related to this plugin. Currently it's only used so you can disable the JSON format if needed.

Custom Properties

Default: On

Whether or not to save the custom properties as metadata in the nodes and resources.

Tile Metadata

Default: Off

Whether or not to save the tile metadata into the TileSet resource. It will be set as a dictionary named tile_meta where the key is the tile global id (the same id used in the Godot TileMap).

Uv Clip (Map only)

Default: On

Enable the Clip Uv (Filter Clip on Sprites) to avoid image bleeding on tiles.

Image Flags

Default: Mipmaps, Repeat, Filter (Note: this is set as Texture.FLAGS_DEFAULT)

The image flags to apply to all imported TileSet images. This will only work if images are embedded, otherwise they will use the flags from their own import settings.

Collision Layer (Map only)

Default: 1

The collision layer for the maps and objects imported. If you need custom layers for each object, consider using a post-import script.

Embed Internal Images

Default: Off

By default, if an image is inside the project, it won't be reimported. If this option is enabled, the images will be embedded into the imported scene. This is useful if you need to use the image somewhere else with different import settings.

Save Tiled Properties

Default: Off

Save the regular properties from Tiled inside the objects as metadata. They will be placed alongside the custom properties.

Note: Not all properties from the file are saved, only the ones you can see on Tiled interface.

Add Background (Map only)

Default: On

Add a parallax background to make the map background color from Tiled. This option is irrelevant if there's no map background color defined in the Tiled map.

Apply Offset (Tileset only)

Default Off

Tilesets on Tiled use the bottom-left as origin, while Godot uses top-left. This option applies an offset to the tileset to make this consistent. It is applied by default on maps to sort out the positioning of everything, but for Tileset importing this is optional.

Post-import script

Default: None

The selected script will have it's post_import(scene) method run. This enables you to change the generated scene automatically upon each reimport.

The post_import method will receive the built scene (or TileSet) and must return the changed scene (or TileSet).

License

MIT License. Copyright (c) 2018 George Marques.