mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Use TileMapLayer for Godot exports as opposed to deprecated TileMap #4106

csueiras posted onGitHub

Describe the bug Tiled exports to Godot using the TileMap node which has been deprecated (https://docs.godotengine.org/en/stable/tutorials/migrating/upgrading_to_godot_4.3.html#id4).

I think the change on the plugin is small-ish, it currently produces this:

[node name="01" type="Node2D"]

[node name="TileMap" type="TileMap" parent="."]
tile_set = ExtResource("TileSet_0")
format = 2
layer_0/name = "Ground"
layer_0/tile_data =  PackedInt32Array(...)

We want:

[node name="01" type="Node2D"]

[node name="Ground" type="TileMapLayer" parent="."]
tile_set = ExtResource("TileSet_0")
use_parent_material = true
tile_map_data = PackedByteArray(...)"

So the primary complexity is implementing the change from the int32 array into the data format in the byte array.

I'm not sure if the specs are documented anywhere, but the Godot code is easy enough to follow as a spec (https://github.com/godotengine/godot/blob/9aed9eca40127bcf21ecd71d25fe8809f345d9e3/scene/2d/tile_map_layer.cpp#L2844) and the marshaling functions are defined here https://github.com/godotengine/godot/blob/9aed9eca40127bcf21ecd71d25fe8809f345d9e3/core/io/marshalls.h.

To Reproduce Steps to reproduce the behavior:

  1. Export a map to Godot
  2. Open map in Godot
  3. See deprecation warning for the use of a TileMap node

Expected behavior The export should not produce a deprecation warning.

Specifications:

  • OS: macOS
  • Tiled Version: 1.11.0

Not exactly sure if this is a bug or a feature request, please feel free to re-label.


Just to note, this would be a breaking change for anyone that is using Godot 4.0-4.2. Not sure if the plugin can read the project file and determine the project version or not.

posted by dogboydog 5 months ago

Yeah I did a good amount of digging into this and even started writing my own export plugin purely in javascript but decided to abandon and use YATI instead. Its easier to make sure things all work well if its an import flow in Godot as opposed to this export mechanism.

Either way the current export plugin can generate the necessary things to then have Godot itself migrate it to a TileMapLayer so that perhaps is wnough of a workaround for the time beinf for most people.

posted by csueiras 5 months ago

Happened to bump into the same issue. TileMap are deprecated so it should at least offer 2 export options, Godot 4 Scene files - TileMap and Godot 4 Scene files - TileMapLayer. For new projects, building the whole tilemap system on something that's deprecated isn't a good option

posted by gab-gil 27 days ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests