-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Godot 4 exporter #3550
Godot 4 exporter #3550
Conversation
Godot 4 overhauled the tilemap system. The old exporter (for Tiled) and the old importer (for Godot) no longer work. This is a first-pass at adding support for Godot 4 to Tiled. This first implementation currently lacks support for: * collisions * non-orthographic maps * non-equilateral grids * animations * objects
@bjorn Looks like there was a temporary internet issue with one of the checks, but otherwise this PR is good to go. Hope it meets your approval! |
@Skrapion I see the builds have succeeded now. :-) Thanks for lot for working towards Godot 4 support in Tiled! Before merging this though, I'd like to know your opinion about including an exporter vs. adding an importer to Godot. A Godot 4 Importer for Tiled maps is being worked on as well. Are there merits for supporting both workflows, and if so, how could we help people decide between the two? |
Thanks for the heads up! I didn't know about the Godot importer. (I suppose that's not surprising when it's only a week old!) I'm biased, but I think an exporter will result in a better user experience most of the time. Pros of importer:
Pros of exporter:
There's not many instances I can think of where you would say "use the importer for this, and use the exporter for that". Here's the only one I can think of:
However, this is mostly just the result of each of us taking the path of least resistance when writing our respective code. Both the importer and the exporter could add an option to produce separate or unified files. |
Hey @Skrapion - Got a question about this exporter. I am building a game with Godot 4 at the moment and I am making use of the tiled world feature inside tiled. I am curious how this exporter would handle this particular Tiled feature. Could you elaborate on this? Thank you for your time
|
@HeadClot Worlds are just a collection of tilemap files, so you should be able to open any of them and export them individually. This exporter won't do a big batch export of every map in the world (that's doable, but 99% of the time I think you'll want to export individual rooms anyway) and you'll still have to link all the maps together somehow in Godot, since how you do that is really game specific. |
Cool. Thank you for the answer :) |
I've got a long travel day on New Years Day, so I might get some more features in. Looking to add:
I hope I'll have enough time to implement at least a couple of those! @bjorn, if you see this message in the next 36 hours, please let me know if you think it's likely that this exporter has no future, so I can work on something else :) |
I missed this message since I was celebrating New Year with my family at my parents. Happy New Year! :-) You've iterated quite well the advantages of this exporter and I'm glad to see you've been able to make further progress with it on your trip! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a number of small comments. I haven't tested the plugin yet, but I'm looking forward to do so when I have more time, hopefully later this week.
Got all four features in that I wanted to get in. No more features on this PR, I promise :) Thanks for the start on the review, @bjorn! |
Chiming in on one more factor in the importer vs. exporter question from a user perspective. In my experience, a useful feature of importers is that objects from tiled can be modified/replaced with in-engine assets, including with custom logic depending on custom properties/layer names, etc. Since an exporter doesn't know anything about your game project code/assets that's something i don't think you can achieve with an exporter. |
Actually, I think this would work quite well. If I add a character to a scene in Godot, with some custom parameters, it outputs something like this:
There's no reason we couldn't make a Tiled exporter output all of that with some custom properties on the objects. And it has the added benefit of those properties being saved into the Tiled project file, so you don't need to re-specify them each time you import, or otherwise find a weird place to save those settings. Making an interface in Godot that can do this would greatly inflate the complexity of the project, so I'm skeptical if anyone would ever do that. The only benefit is that, if someone did that, the user might be able to specify some of these properties by selecting an item from a list instead of typing it in. |
Yes, I did assume you were talking about having a GUI to help you. And in that case, the increased complexity I was referring to was for the person writing the importer, not the end user. I guess you're using this importer? If the primary use case is replacing Tiled objects with packed scenes, and maybe adding some custom properties, then I think we can eliminate the need to write your own import script entirely. In other words, instead of:
All you have to do is:
And that's it. As soon as you click File->Export in Tiled, Godot would instantly reload your level and replace that object with the Lamp.tscn scene. We could even specify an object root and get rid of the "res://objects" part. |
You're right, a custom enum would be perfect for this. And yes, 'type' was just an example :) |
Hey yall! Just found this exporter and im really excited for it. Godot tilemap editor dont really work the way i want. Is this usabale yet or how long before i can start using it? :) Have a good one! |
It hasn't been merged yet (what do you think, @bjorn?) but you can download it and use it right now. Just click on the Details link for any "Build Packages" below, then click to "Summary" and scroll down to "Artifacts". |
* Renamed some functions to start with lower case (coding style) * Fixed translation issues (lupdate does not recognize source texts when not provided as direct parameter to known tr / translate functions) and use consistent translation context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skrapion I think this is great work and I'm in the process of trying to test this (have installed Godot 4 Beta, looking into setting up a project) and reviewing the code (pushed some small changes).
* Pass QString by const& in a few places * Don't use regular expression to replace " by \" * Use range-based for loop for iteration in a few places * Avoid double tilesetInfo lookup in addTileset * Use TileLayer::localBounds when we're using it to iterate the layer's tiles
All layer types support the following custom properties: | ||
|
||
* bool ``ySortEnabled`` (default: false) | ||
* int ``zIndex`` (default: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tried exporting one of the examples, it did not look like in Tiled because the layers appeared to get rendered in a random order. Would it make sense to use an auto-incrementing z-index by default, instead of using 0 for each layer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you use ySortEnabled?
Are you recommending that reach Tiled later gets a new z-index? We can play with that, but I'm a little nervous about how magic that is, and how you might end up with layer numbers changing unexpectedly.
Right now it's just using the Godot defaults, but I'm happy to change them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not use ySortEnabled
. I might have just been confused with what Godot was displaying, probably being in editing mode. When not in editing mode, it seems the layer order defines rendering order, so setting zIndex
does not appear necessary.
Glad you sorted it out, @dogboydog. Hopefully when the documentation is published it will be a little more obvious how those features work. But it sounds like until object experts are supported, that error message should be changed to a warning message. Unfortunately, I'm traveling for two weeks, so it won't happen just yet. The main reason why exportAlternates isn't on by default is because Godot's handling of rotated and flipped tiles requires you to octuple the size of your tile set, so I thought it was more responsible to have the user opt into it. |
Got it, thanks for explaining. And nice work on the exporter. |
There was little reason to fail the export in these cases, which are now reported as errors or warnings in the Console view instead: * WARNING: Unsupported layer type encountered * WARNING: Only rectangles or polygons supported for collissions * ERROR: Tile animations have gaps * ERROR: Tile used that is also part of an animation * ERROR: Unsupported tile flipping (120 degree or missing exportAlternates) The choice between error or warning is a little arbitrary, since none of these cause the export to fail and all of them cause the export to only partially work. I picked warnings for cases where I think some people may want to just ignore them. The errors and warnings also enable jumping to the respective location, layer or tile, where applicable.
I've changed a number of these hard errors into warnings / errors that now get reported to the status bar / Console view. I think the plugin is in good shape, even if more features could be added, so I would propose to merge this for now. Further improvements and potential bugfixes can be made in future PRs. :-) Regarding export plugin or Godot importer, it sounds to me like it'll be good to have both since there are pros / cons on both sides. |
Hi all where can i download to test this feature? Kinda confused which link to access or where to find the build packages. I would like to test this in Godot RC5 |
The documentation for this new Godot 4 export plugin can be found at https://doc.mapeditor.org/en/latest/manual/export-tscn/. Any feedback is welcome. The most obviously missing feature is probably the support for object layers. If you're missing this, please also share with us your expectations for this feature. |
will there be new updates for this feature? it would be nice to have:
and this would really be better to have this option |
@erniel These are all good suggestions. I think the features of this exporter will generally be expanded on-demand and when there is a clear idea about how each of these should be implemented. Do you personally need all of these, or are some features more important than others? And can you help define exactly how each feature can be best mapped from Tiled to Godot 4, or even help implement them? |
Hey there, |
@feendrache I think the discussion above showed that there are advantages to using an importer vs. an export plugin, but if this export covers your needs you of course don't need to maintain an importer. Note that there is another importer in development in the meantime as well (not sure if they were aware of yours) at https://github.com/Kiamo2/YATI. It seems to already cover most of Tiled's features. |
@bjorn thx ... oh well... that's brilliant, so i will stop maintaining mine and redirect interested people to this one |
Merry Christmas!
Godot 4 is currently in beta and expected to release before GDC 2023 in March. This version overhauled the tilemap system, so the old exporter (for Tiled) and the very old importer (for Godot) no longer work. This is a first-pass at adding first-class support for Godot 4 to Tiled.
I intend to complete the following before I submit this for merging:
Potential projects for future pull requests include (by estimated order of difficulty):