godot-tiled-importer icon indicating copy to clipboard operation
godot-tiled-importer copied to clipboard

"Child" class attributes not mapped in Godot as metadata

Open bitbrain opened this issue 2 years ago • 0 comments

Plugin version

Plugin version: 2.4 Godot Version: 3.4 Tiled version: 1.8, 1.9

(downloaded from Github

Issue description

Child object attributes not configured when importing tilemaps. For example, if I create a new class "House" and another class "Sofa" and add attributes to sofa, and I configure "Sofa" to be a child attribute of House, then the attributes of Sofa are not available in Godot.

Additionally, when currently trying to set this up, Godot will show the following errors:

 res://addons/vnen.tiled_importer/tiled_xml_to_dict.gd:291 - Invalid get index 'properties' (on base: 'int').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').
 res://addons/vnen.tiled_importer/tiled_map_reader.gd:1151 - Invalid get index 'y' (on base: 'Nil').

Steps to reproduce

  1. Download tiled-1.9-demo-project.zip
  2. Try to import the .tmx file with Godot

Expected behaviour: child objects with attributes are accessible in Godot Current behaviour: child objects with attributes get ignored in Godot

Potential solution

Given a custom class with object references and other attributes that is used as a field within another class, when parsing the object in the world, create a child node of type Node and add it to the current Godot node object. Then, configure the attributes on that child Node as metadata. Repeat this process recursively.

bitbrain avatar Jul 22 '22 10:07 bitbrain

I'll have a PR up for this soon.

bitbrain avatar Jul 24 '22 09:07 bitbrain