mapeditor / tiled-to-godot-export

Tiled plugins for exporting Tilemaps and Tilesets to Godot 3 format
149 stars 35 forks source link

Exporting Object with Type Area2D #28

Closed rainbowlotus-games closed 3 years ago

rainbowlotus-games commented 3 years ago

So, it is unclear to me if this is supported, therefore I tried it. I created an object layer, and set up a rectangle in it. I gave it the Type of Area2D. When I export the map as a Godot Scene I get the following error:

ReferenceError: removeUndefined is not defined.

Stack traceback:
  addSubResource@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:55
  setTileMapsString@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:169
  write@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:35
  write@file:///C:/path/to/Tiled/extensions/tiled-to-godot-export-master/export_to_godot_tilemap.js:487

The error seems to happen at this point in the script:

const shapeId = this.addSubResource("RectangleShape2D", {
    extents: `Vector2( ${width}, ${height} )`
});

Tried it with a Tile of the Area2D type as well, that didn't give an error, but I also didn't get the Area2D in Godot. I might just be trying something that shouldn't even work yet, or maybe I am doing something wrong... Any help is appreciated! :)

Edit: I commented out this line: removeUndefined(contentProperties); The method "removeUndefined" isn't defined so... now it works...sort of. The exported Area2D doesn't have the correct scale inside of Godot :(

bjorn commented 3 years ago

@rainbowlotus-games Sorry, I've removed removeUndefined in 6d84e4df8c3a44e13bedbf078f2e5ec5cd7ec174 and didn't realize the function might have usages outside of the file in which it was defined. I'll suggest a fix for this soon.

The exported Area2D doesn't have the correct scale inside of Godot :(

In what way is the scale not correct?

rainbowlotus-games commented 3 years ago

Whoops, seems that problem was on my end alone. It had to do with the viewport and project settings, apologies. Area2D works now, with removeUndefined commented out!