Giter Club home page Giter Club logo

tiled-to-godot-export's People

Contributors

agmcleod avatar alextrevisan avatar bjorn avatar devharts avatar eleniums avatar feldc avatar konsumer avatar mcarpenter622 avatar mikemnd avatar nerochiaro avatar srekel avatar treeways avatar xorus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiled-to-godot-export's Issues

Navigation support?

Hey,

I'm trying to add Navigation to my tiles, but it seems the type "navigation" is not yet supported. Is that correct?
As in, I expect adding "navigation" as the type of the tile, it would create a NavigationPolgyon node and so on, to the Sprite, in the Godot scene. Also, even if this would work, a TileMap needs a Navigation2D node as the parent - currently the parent of each TileMap is just a Node2D. So how would this work? Am I better off in just having anything I want to be navigatable on a seperate, Godot only TileMap, for now?

fix newlines on linux/mac

This is from discussion on #5

I am on Linux, and it seems to be interpreting newlines in map file differently:

Screenshot from 2020-04-14 13-34-28

Area2D objects have wrong meta exported

When exporting Area2D objects, the meta of the layer is exported to the Area2D instead of that of the object itself.
Additionally, the same wrong meta is also exported to the CollisionShape2D that is created as child of the Area2D.

Tiled 1.9 future compatibility: API renamed "type" object property to "className"

Tiled 1.9 was recently released. I noticed that one of the changes is renaming the property "type" to "class" for all data types as per the release notes.

Object Types have been merged into the Property Types, now simply called “Custom Types”. This means custom classes can now have a color and can be used as “object type”. If your project refers to an object types file, these types will be automatically imported as custom classes. If you used globally stored object types before, they can be manually imported to your project.

In addition, the “Type” property previously available only for objects and tiles is now available for all data types as the new “Class” property. For consistency, this value is written out as “class” also for objects and tiles, but a project-wide compatibility option is provided to make it still write out as “type”:

This is confirmed by the plugin API documentation.

This API change shouldn't affect this project today, as I believe the new className property is still accessible as "type" (although marked deprecated), but it might be worth taking note in case it becomes a future issue. As far as I can tell, this would affects us when we want to distinguish which type of Node to create for a given Tiled object.

One consideration is making sure the plugin remains compatible with previous versions of Tiled. We could simply test for the presence of a "className" property on the object and fallback to "type", or we could also test tiled.version to switch behaviors. It's also worth noting that Tiled projects (but not individual maps) now have the ability to save files in "compatibility mode", which keeps the 1.8 API intact, but I'm not sure this would affect us since we are using the export path.

I'm reporting this simply as a TODO. The changes seem simple enough and I'd be happy to contribute if the maintainer would prefer.

Handling layer with multiple tilesets: multiple scenes?

Just an idea:
In the same way that multiple tilemap, layers are handled by generating multiple subscenes in godot, perhaps a single tilemap layer that has multiple tilesets could also be split out into subscenes? Each layer could be a Node that has each set used as a tilemap, or maybe only tilemaps that have multiple tilesets used would generate a child tilemap parented to the layers base tilemap.

Add tests

It would be good to add some small Tiled example maps and the expected output of this plugin, at least for manual testing but it would also be nice to run them automatically on GitHub Actions.

Such tests help ensure the extension really outputs what it is expected to output, especially after changes have been made.

Tilemap flags - Filter

Hi,
I'm importing maps and sets successfully to Godot 3.3.2, but regardless of Import Settings ("Tileset from Tiled") on the tileset resource (.tsx) my pixel tiles blur as if the Filter flag were on (whether or not it is). I've tried the preset "Pixel Art" but there is no change.
Is this a matter of the tool not being updated yet for 3.3, or have I missed a step in the process?

How do I use this?

Here is what I tried:

  • I have a simple map that uses terrain brushes
  • I export the tileset with projectRoot set to assets
  • I export map with projectRoot set to assets
  • When I import scn file into godot, it says the asset can't be found, looks like it added the full path, so I set it to the project-relative path with "Fix Dependencies"
  • I get another error the png file is missing (seems like it's looking for full-pth in res:// again) so I hand-edit to 2 files to make sure the paths are correct

I still get this error:

 scene/resources/resource_format_text.cpp:175 - Couldn't load external resource: res://Terrain.tres
 editor/editor_data.cpp:798 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).
 editor/editor_data.cpp:627 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).
 editor/editor_data.cpp:677 - Index p_idx = 2 is out of bounds (edited_scene.size() = 2).

Is it because I'm using a map with terrain-brushes?

OSX: 10.14.6 (Mojave)
Tiled: 1.3.3
Godot: 3.2.1

Here is a test project:
tester.zip

Start using JavaScript modules

Since Tiled 1.8, there is support for JavaScript modules. Tiled will load JS files as modules when they have a .mjs extension. This enables the use of import and export.

Since this extension uses some shared code (utils.js), using JS modules would be the perfect way to encapsulate this shared code such that these helper functions don't pollute the global scope.

[feature] Smarter path resolution & default projectRoot

This is from discussion on #5

Relative and godot-external paths would help me support different use-cases, like sharing my projects on github (where other developers won't have same file-locations.)

This is totally workable as it is. Very easy to set 1 property to my maps/tile-sets. I wonder though if a sensible default like res:// might be all it needs for it to work on github, with relative paths.

Maybe this logic would do it?

  • check for projectRoot
  • Use it as absolute, if it doesn't start with .
  • If projectRoot is not set, set it to current-files location (this would allow tiled files in the godot project root)
  • if projectRoot starts with res:// use it as-is to work out relative-to-godot-root path, like for a sub-dir

This would handle these use-cases:

  1. I put all my files in godot's project-root (just leave projectRoot blank)
  2. I put all my tiled files somewhere else, completely out of godot's root (set projectRoot to an absolute path)
  3. I put all my files in some relative dir, that is maybe outside of godot's root (set projectRoot to something like ../godot-game
  4. I put all my files in some sub-dir of godot root (set projectRoot to res://assets or whatever)

For use-case 2 & 3, I think we'd need to copy image-file, so we'd need to infer res:// from the path. We know the relative location between tile & image and map & tile, and where we are outputting godot files, so if projectRoot points to something outside of output-location we'd copy files (need to look into how to do this, or if it's even possible.)

Tasks

  • Add support for relative locations in projectRoot
  • Add "Where is res://" to README, simplify instructions (offer the default all-in-godot-root as simplest) and make sure to include specific examples

Flipped tiles not flipped after exporting

Hello, thankyou so much for creating this plugin.
I tried to export a tilemap with flipped tiles (in Tiled), but they are not flipped when I open the map in Godot 3.2.
Just to check, I tried adding flipped tiles using godot, and it works correctly using an exported tilemap.

tileset.asset.fileName returns `null` in export_to_godot_tilemap.mjs

I was having difficulty utilizing the relativePath property exporting a TileMap when, upon testing, realized it would properly set the ext_resource in the final .tscn if I specified the exact path to the tileset (e.g. /Assets/Maps/Town/town_map.tres).|

This did not happen with Tilesets, as the exported .tres properly linked to their source image without projectRoot or relativePath needing to be specified.

I dug around the source code only to find that tileset.asset.fileName in setTilesetsString() returned null when tileset.asset returned a proper object reference, resulting in relativePath only working if it included the tileset file name as well.

image
image

Folders not working and animated tiles dont animate

Hey, first of all, thank you so much for this extension.
Me and my team are recreating Pokemon Uranium in godot and your extension makes it so much easier.
That being said, i have encountered a few small things that arent working correctly:
When using folders in the tiled file, the tscn file will be an empty scene with only a node2d as root
and when i have animated tiles, they get converted to normal tiles
would it be possible to fix these two things?
best regards

File paths on .tres export

I run godot on a external drive. D://Godot/Project file/tileName.png
I have to manually change the .tres file to not use D://HDD Desktop/godot/making tiles/"tileName.png

My personal notes:

  1. Click Map and file Export as .tscn file in folder
  2. Click tileset and file Export as .tres in folder
  3. Manually edit .tres folder to remove full path ie: "D://HDD Desktop/godot/making tiles/" (in this use case leave "assets" and beyond alone but leave "res://"
  4. Open .tcsn file in Godot under FileSystem (fix .tres location)
  5. click (empty) under "Inspector next to "tile set" and select the .tres file.
  6. repeat step 5. on each layer.

Name error and wrong path

Hey, here are the 2 issues I reported in the comments of the video:
*When exporting the tilemap as .tscn file, Tiled adds a dot "." in front of the file name (ex: MyMap..tscn), which gives errors when importing the scene in Godot. I just had to remove it to make it work.
Is it normal that the name has an extra dot? I'm not sure if it's okay to remove it.

*The other problem is the path in the files. I paid attention to the forward slash when I typed in the projectRoot but the path in the exported files isn't correct.
All my files are located in a "Level" directory (at the root of the Godot project), but the path in the .tres file is "res://Urban tileset.png" instead of "res://Level/Urban tileset.png".
Same error in the .tscn, the path is "res://Urban tileset.tres".
The consequence is that Godot thinks the files are in the root whereas they are in the directory "Level". Then Godot doesn't find them.

I'm using windows 10 by the way. I managed to export my maps anyway but I'm not sure if I did something wrong, I just hope that my message will be useful for your eventual updates or even other people experiencing the same issue as me.
Kind regards.

Isometric support?

Is isometric support planned soon? The godot TilEd importer supports isometric tiles, but it breaks completely with object positions and this exporter is the only other option for getting TilEd maps into Godot.

Exporting undefined property

Hi, first of all, thanks for the exporter!

But there is a problem when exporting tilesets. The final file (line 10) is like this:

0/region = Rect2( 0, 0, undefined, undefined )

and I believe is this line but I dont know how to fix:

0/region = Rect2( 0, 0, ${this.tileset.imageWidth}, ${this.tileset.imageHeight} )

Thanks

EDIT: Works on Snapshot Windows version: Version 2020.04.10

Collision rectangles in wrong spots.

I think this might be because i have a larger image that's not full of tiles yet. The original tiled importer seemed to pull in collisions okay, but i had other issues with it.

image

I double checked the tsx file, I have collision rects over the water tiles on the right, the hedges & rocks. Nothing on the right side where it's blank.

Here's the map files as well:

outside-tiles.zip

I'll see if I can take some time to have a look at this (i'd love to build out navigation tiles as well)

Exporting Object with Type Area2D

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 :(

Z Index support

It would be nice to be able to adjust the Z Index on specific tiles from the tiled editor. This would help with tiles that should cover other objects. As an example, the game I am working on has a doorway, the player sprite should walk under the doorway, but right now it walks on top of the doorway.

I am able to achieve this result manually by modifying the tileset that gets exported and setting the specific tile to have a Z Index of 1. However if I reexport the project this gets overridden and I have to redo all the Z Indexes in the tileset. The ideal solution would be to allow a custom property on a tile called "zIndex" which should be an integer, this should get exported to the godot tileset format.

Here is an example godot tileset that uses the z index:

[gd_resource type="TileSet" load_steps=5 format=2]

[ext_resource path="res://maps/dungeon.png" type="Texture" id=1]

[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 9, 0, 54, 0, 54, 54, 9, 54 )

[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 6, 0, 54.5, 0, 54.5, 53.5, 6, 53.5 )

[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 6, 0, 54.5, 0, 54.5, 53.5, 6, 53.5 )

[resource]
0/name = "dungeon 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 1024, 1024 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 64, 64 )
0/autotile/spacing = 0
0/autotile/occluder_map = [  ]
0/autotile/navpoly_map = [  ]
0/autotile/priority_map = [  ]
0/autotile/z_index_map = [ Vector3( 3, 9, 1 ) ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape = SubResource( 1 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 14, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 1 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 13, 12 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 2 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 9, 15 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0

The important line to generate is:
0/autotile/z_index_map = [ Vector3( 3, 9, 1 ) ]

This indicates that the tile located at x = 3 and y = 9 is set to a Z Index of 1. This means the player passes under that tile because the player I have is set to Z Index 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.