Kiamo2 / YATI

Addon to import Tiled maps into Godot 4
MIT License
140 stars 16 forks source link

add_id_as_metadata does not work on instance items #50

Closed Lertsenem closed 2 weeks ago

Lertsenem commented 1 month ago

Describe the bug I can't get the Tiled objects ID as "id" metadata in Godot for instance objects (ie class = instance and res_path is set to a Godot scene). I would like to use it to link some objects together (in this case two teleportation devices) using Tiled "object" property.

To Reproduce

  1. Create a tiled map with an object layer
  2. Add an object and set its class to "instance"
  3. Add a custom file property res_path and set it to a godot tscn path
  4. Set the option add_id_as_metadata in Godot, and import your map
  5. Check the map, the object should be there, but without any "id" metadata.

Expected behavior Object should have the id metadata.

Desktop (please complete the following information):

Additional context It looks like the add_class_as_metadata option has the same issue.

Kiamo2 commented 1 month ago

Got a bunch of issues now which I will resolve all together with one release addressing also changes for Godot 4.3 as soon as it's stable version is released.

This can take a while.

For the moment you can fix your issue by inserting the following 4 lines:

      if _add_class_as_metadata and class_string != "":
          instance.set_meta("class", class_string)
      if _add_id_as_metadata and obj_id != 0:
          instance.set_meta("id", obj_id)

into file TilemapCreator.gd just behind line 761 (instance.visible = obj_visible)

Lertsenem commented 1 month ago

Thanks, the workaround works. :)

Kiamo2 commented 2 weeks ago

Should be now fixed with release 1.6.8 / 2.0.0