Kiamo2 / YATI

Addon to import Tiled maps into Godot 4
MIT License
141 stars 18 forks source link

Fix issue with using different tilesets that use the same tile IDs #33

Closed lmReef closed 10 months ago

lmReef commented 10 months ago

Just made a quick fix for an issue I was having where if you try to use different tilesets in Tiled that contain tiles with identical IDs the latter tile gets skipped.

Note I made the changes assuming that replacing the manually tracked _atlas_source_counter can be replaced with the return value of TileSet.add_source() where it gets the next source id itself. I'm not too sure if this is something ya want to add but it fixed an issue for me so thought I'd put up a pr :) Feel free to change it if you like

Example

In Tiled Editor

Screenshot 2023-12-07 151545

Godot scene result before changes

Screenshot 2023-12-07 151813

Godot scene result after changes

Screenshot 2023-12-07 151545

Related Godot console errors

Screenshot 2023-12-07 151848 https://github.com/godotengine/godot/blob/2f73a059cefadcd944b6874f2557ec82e46a562d/scene/resources/tile_set.cpp#L475

Kiamo2 commented 10 months ago

Looks promising, I'll test that with all my examples (which can take a while).

Kiamo2 commented 10 months ago

Very smart fix, no more atlas source counting!