mapeditor / tiled-to-godot-export Goto Github PK
View Code? Open in Web Editor NEWTiled plugins for exporting Tilemaps and Tilesets to Godot 3 format
Tiled plugins for exporting Tilemaps and Tilesets to Godot 3 format
Hey,
I'm trying to add Navigation to my tiles, but it seems the type "navigation" is not yet supported. Is that correct?
As in, I expect adding "navigation" as the type of the tile, it would create a NavigationPolgyon node and so on, to the Sprite, in the Godot scene. Also, even if this would work, a TileMap needs a Navigation2D node as the parent - currently the parent of each TileMap is just a Node2D. So how would this work? Am I better off in just having anything I want to be navigatable on a seperate, Godot only TileMap, for now?
HI Mike, please take a look at https://github.com/justdaft/tiled-to-godot-export/commits/master
I have added a couple of new features, if they are usefull to anyone I am happy to do PR, please ignore my poor javascript skills, feel free to make any changes or suggestions.
Thanks
Billy
This is from discussion on #5
I am on Linux, and it seems to be interpreting newlines in map file differently:
When exporting Area2D objects, the meta of the layer is exported to the Area2D instead of that of the object itself.
Additionally, the same wrong meta is also exported to the CollisionShape2D that is created as child of the Area2D.
Request support for importing placed collection of images into Godot.
Tiled 1.9 was recently released. I noticed that one of the changes is renaming the property "type" to "class" for all data types as per the release notes.
Object Types have been merged into the Property Types, now simply called “Custom Types”. This means custom classes can now have a color and can be used as “object type”. If your project refers to an object types file, these types will be automatically imported as custom classes. If you used globally stored object types before, they can be manually imported to your project.
In addition, the “Type” property previously available only for objects and tiles is now available for all data types as the new “Class” property. For consistency, this value is written out as “class” also for objects and tiles, but a project-wide compatibility option is provided to make it still write out as “type”:
This is confirmed by the plugin API documentation.
This API change shouldn't affect this project today, as I believe the new className property is still accessible as "type" (although marked deprecated), but it might be worth taking note in case it becomes a future issue. As far as I can tell, this would affects us when we want to distinguish which type of Node to create for a given Tiled object.
One consideration is making sure the plugin remains compatible with previous versions of Tiled. We could simply test for the presence of a "className" property on the object and fallback to "type", or we could also test tiled.version
to switch behaviors. It's also worth noting that Tiled projects (but not individual maps) now have the ability to save files in "compatibility mode", which keeps the 1.8 API intact, but I'm not sure this would affect us since we are using the export path.
I'm reporting this simply as a TODO. The changes seem simple enough and I'd be happy to contribute if the maintainer would prefer.
Since a while we have an NPM package called tiled-api
: https://www.npmjs.com/package/@mapeditor/tiled-api
Using it in an extension enables code completion and API documentation to show up in a JS editor, like VS Code. It would be nice to set this up for this extension as well.
Just an idea:
In the same way that multiple tilemap, layers are handled by generating multiple subscenes in godot, perhaps a single tilemap layer that has multiple tilesets could also be split out into subscenes? Each layer could be a Node that has each set used as a tilemap, or maybe only tilemaps that have multiple tilesets used would generate a child tilemap parented to the layers base tilemap.
It would be good to add some small Tiled example maps and the expected output of this plugin, at least for manual testing but it would also be nice to run them automatically on GitHub Actions.
Such tests help ensure the extension really outputs what it is expected to output, especially after changes have been made.
Hi,
I'm importing maps and sets successfully to Godot 3.3.2, but regardless of Import Settings ("Tileset from Tiled") on the tileset resource (.tsx) my pixel tiles blur as if the Filter flag were on (whether or not it is). I've tried the preset "Pixel Art" but there is no change.
Is this a matter of the tool not being updated yet for 3.3, or have I missed a step in the process?
Are there any plans to update this to work with Godot 4?
Here is what I tried:
projectRoot
set to assets
projectRoot
set to assets
res://
again) so I hand-edit to 2 files to make sure the paths are correctI still get this error:
scene/resources/resource_format_text.cpp:175 - Couldn't load external resource: res://Terrain.tres
editor/editor_data.cpp:798 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).
editor/editor_data.cpp:627 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).
editor/editor_data.cpp:677 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).
Is it because I'm using a map with terrain-brushes?
OSX: 10.14.6 (Mojave)
Tiled: 1.3.3
Godot: 3.2.1
Here is a test project:
tester.zip
Since Tiled 1.8, there is support for JavaScript modules. Tiled will load JS files as modules when they have a .mjs
extension. This enables the use of import
and export
.
Since this extension uses some shared code (utils.js), using JS modules would be the perfect way to encapsulate this shared code such that these helper functions don't pollute the global scope.
This is from discussion on #5
Relative and godot-external paths would help me support different use-cases, like sharing my projects on github (where other developers won't have same file-locations.)
This is totally workable as it is. Very easy to set 1 property to my maps/tile-sets. I wonder though if a sensible default like res://
might be all it needs for it to work on github, with relative paths.
Maybe this logic would do it?
projectRoot
.
projectRoot
is not set, set it to current-files location (this would allow tiled files in the godot project root)projectRoot
starts with res://
use it as-is to work out relative-to-godot-root path, like for a sub-dirThis would handle these use-cases:
projectRoot
blank)projectRoot
to an absolute path)projectRoot
to something like ../godot-game
projectRoot
to res://assets
or whatever)For use-case 2 & 3, I think we'd need to copy image-file, so we'd need to infer res:// from the path. We know the relative location between tile & image and map & tile, and where we are outputting godot files, so if projectRoot
points to something outside of output-location we'd copy files (need to look into how to do this, or if it's even possible.)
projectRoot
res://
" to README, simplify instructions (offer the default all-in-godot-root as simplest) and make sure to include specific examplesHello, thankyou so much for creating this plugin.
I tried to export a tilemap with flipped tiles (in Tiled), but they are not flipped when I open the map in Godot 3.2.
Just to check, I tried adding flipped tiles using godot, and it works correctly using an exported tilemap.
ignore me. Worlds will make it possible.
I was having difficulty utilizing the relativePath
property exporting a TileMap when, upon testing, realized it would properly set the ext_resource
in the final .tscn if I specified the exact path to the tileset (e.g. /Assets/Maps/Town/town_map.tres
).|
This did not happen with Tilesets, as the exported .tres properly linked to their source image without projectRoot
or relativePath
needing to be specified.
I dug around the source code only to find that tileset.asset.fileName
in setTilesetsString()
returned null when tileset.asset
returned a proper object reference, resulting in relativePath
only working if it included the tileset file name as well.
Hey, first of all, thank you so much for this extension.
Me and my team are recreating Pokemon Uranium in godot and your extension makes it so much easier.
That being said, i have encountered a few small things that arent working correctly:
When using folders in the tiled file, the tscn file will be an empty scene with only a node2d as root
and when i have animated tiles, they get converted to normal tiles
would it be possible to fix these two things?
best regards
I run godot on a external drive. D://Godot/Project file/tileName.png
I have to manually change the .tres file to not use D://HDD Desktop/godot/making tiles/"tileName.png
My personal notes:
Hey, here are the 2 issues I reported in the comments of the video:
*When exporting the tilemap as .tscn file, Tiled adds a dot "." in front of the file name (ex: MyMap..tscn), which gives errors when importing the scene in Godot. I just had to remove it to make it work.
Is it normal that the name has an extra dot? I'm not sure if it's okay to remove it.
*The other problem is the path in the files. I paid attention to the forward slash when I typed in the projectRoot but the path in the exported files isn't correct.
All my files are located in a "Level" directory (at the root of the Godot project), but the path in the .tres file is "res://Urban tileset.png" instead of "res://Level/Urban tileset.png".
Same error in the .tscn, the path is "res://Urban tileset.tres".
The consequence is that Godot thinks the files are in the root whereas they are in the directory "Level". Then Godot doesn't find them.
I'm using windows 10 by the way. I managed to export my maps anyway but I'm not sure if I did something wrong, I just hope that my message will be useful for your eventual updates or even other people experiencing the same issue as me.
Kind regards.
Is isometric support planned soon? The godot TilEd importer supports isometric tiles, but it breaks completely with object positions and this exporter is the only other option for getting TilEd maps into Godot.
Hi, first of all, thanks for the exporter!
But there is a problem when exporting tilesets. The final file (line 10) is like this:
0/region = Rect2( 0, 0, undefined, undefined )
and I believe is this line but I dont know how to fix:
0/region = Rect2( 0, 0, ${this.tileset.imageWidth}, ${this.tileset.imageHeight} )
Thanks
EDIT: Works on Snapshot Windows version: Version 2020.04.10
I think this might be because i have a larger image that's not full of tiles yet. The original tiled importer seemed to pull in collisions okay, but i had other issues with it.
I double checked the tsx file, I have collision rects over the water tiles on the right, the hedges & rocks. Nothing on the right side where it's blank.
Here's the map files as well:
I'll see if I can take some time to have a look at this (i'd love to build out navigation tiles as well)
So, it is unclear to me if this is supported, therefore I tried it. I created an object layer, and set up a rectangle in it. I gave it the Type of Area2D. When I export the map as a Godot Scene I get the following error:
ReferenceError: removeUndefined is not defined.
Stack traceback:
addSubResource@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:55
setTileMapsString@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:169
write@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:35
write@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:487
The error seems to happen at this point in the script:
const shapeId = this.addSubResource("RectangleShape2D", {
extents: `Vector2( ${width}, ${height} )`
});
Tried it with a Tile of the Area2D type as well, that didn't give an error, but I also didn't get the Area2D in Godot.
I might just be trying something that shouldn't even work yet, or maybe I am doing something wrong... Any help is appreciated! :)
Edit: I commented out this line: removeUndefined(contentProperties);
The method "removeUndefined" isn't defined so... now it works...sort of.
The exported Area2D doesn't have the correct scale inside of Godot :(
It would be nice to be able to adjust the Z Index on specific tiles from the tiled editor. This would help with tiles that should cover other objects. As an example, the game I am working on has a doorway, the player sprite should walk under the doorway, but right now it walks on top of the doorway.
I am able to achieve this result manually by modifying the tileset that gets exported and setting the specific tile to have a Z Index of 1. However if I reexport the project this gets overridden and I have to redo all the Z Indexes in the tileset. The ideal solution would be to allow a custom property on a tile called "zIndex" which should be an integer, this should get exported to the godot tileset format.
Here is an example godot tileset that uses the z index:
[gd_resource type="TileSet" load_steps=5 format=2]
[ext_resource path="res://maps/dungeon.png" type="Texture" id=1]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 9, 0, 54, 0, 54, 54, 9, 54 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 6, 0, 54.5, 0, 54.5, 53.5, 6, 53.5 )
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 6, 0, 54.5, 0, 54.5, 53.5, 6, 53.5 )
[resource]
0/name = "dungeon 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 1024, 1024 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 64, 64 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ Vector3( 3, 9, 1 ) ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 1 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 14, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 13, 12 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 15 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0
The important line to generate is:
0/autotile/z_index_map = [ Vector3( 3, 9, 1 ) ]
This indicates that the tile located at x = 3 and y = 9 is set to a Z Index of 1. This means the player passes under that tile because the player I have is set to Z Index 0.
This plugin cannot currently export animated tiles to Godot.
Some information about animated Tiles in Tiled:
https://doc.mapeditor.org/en/stable/manual/editing-tilesets/#tile-animation-editor
Some information about how animated Tiles in Godot can be implemented:
https://kidscancode.org/godot_recipes/2d/tilemap_animation/
https://www.youtube.com/watch?v=7mg2YKujcJ4
Are one-way collisions still planned?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.