vnen / godot-tiled-importer Goto Github PK
View Code? Open in Web Editor NEWPlugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets
License: MIT License
Plugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets
License: MIT License
Hello,
I'm trying to automatically add a player to the scene.
here the code of my post_import script:
extends Node
var player = preload("res://Scene/Player.tscn")
func _ready():
pass
func post_import(scene):
var p = player.instance()
scene.add_child(p)
return scene
The scene don't seem to be affected by my change since the player isn't in the scene.
But if I return "p", the player instance, the scene imported is an copy of the player scene which mean the code is correctly executed.
I'm still new to Godot Engine, this code should work, right ?
Apparently Godot has some issues when converting float to int, making the detection not work correctly. Also, the flips are not translated correctly to the Godot system.
In the upcoming Tiled 1.1.0 release there is a feature Called Infinite maps.
Would it be possible to support this new feature?
Just curious,
HeadClot
I was testing the addon on one of Tiled's example files (/examples/orthogonal-outside.tmx) -- the provided objects do not have a GID and their id's are arbitrary (do not point to an actual tileset) and so an import error was thrown.
I traced it to this snippet.
Wouldn't it be possible to silently ignore this warning and use any random tile for the objects? (Assuming it's necessary to have one as a placeholder).
This seems to make more sense, as setting object GIDs is, by design, optional, and this is one area where we're breaking compatibility with Tiled when it could perhaps be avoided.
What do you think?
P.S. Thanks for this addon, I must say it's really great! :D
returns, this error msg:
res://addons/vnen.tiled_importer/tiled_map.gd:169 - Invalid operands 'int' and 'String' in operator '+'
Plugin version
I am using Godot 3.0 stable
Downloaded from the Asset Library
Issue description
problems in large maps. you see lines. maps of size 100 * 100 tiles.
Steps to reproduce
when loading large maps you see lines that should not be.
https://mega.nz/#!PIcx3JhT!njhsSth9eSGq8NCxk1BmHk-u4eLKbB_Qg-J3RRujI38
Right now the importer supports collision geometry, occluders, etc based on annotation in the object properties...
Would it be possible to extend this to allow bringing over something as an Area2D (instead of e.g. a StaticBody2D)? This, combined with the custom property annotations which convert to metadata, would allow some powerful automated functionality w/i games (e.g. creating teleporters to connect tiled maps).
I imagine this would be pretty straightforward to implement and I'm open to putting together a PR, I just haven't bothered to look at the plugin code, yet. Any pointers would be appreciated.
As it is, I think I could implement this in my own project via scraping and recreating an area2D at the position of a staticbody2d and removing the child beneath it and adding that collision shape to the newly created Area2D instead. But it would seem cleaner and less work at run time to handle this during the import (also wouldn't have to move over metadata).
If the user want to process information from Tiled maps, they could supply a script with functions to apply to the generated scene. This would make the import process seamless and remove the need for an extra step, while still making it flexible enough to many use cases.
Hi, I can't seem to use tile_meta to access Tiled .tsx Tile properties - even when I've enabled the import option.
I searched tile_meta, and set_meta in the repository and "tile_meta" doesn't seem to exist.
How do I access custom Tile properties now?
Hello,
I'm trying to import a map with an object which contain a custom property:
I check the checkbox is check in the import window
But my test script I put on the objects layer don't see anything:
print("Metadata list:")
for i in get_children():
print(i.get_meta_list())
Here the output i have :
Metadata list:
[]
I use the 2.1.3 version of Godot (the Steam one) and the last version of Tiled version 1.0.0
What am I doing wrong ?
I'm having a hard time understanding how to define collision shapes for my tileset. It is not explained in the readme file and I've noticed the code around line 206 deals with it but I cannot understand what it is expecting from the tmx file.
Add an option for that in the importer dialog.
Hello, the concave collision is not working on import of a tileset (godot 3.0) all are showing up convex.
Is there a way to change the shape manually? like in the .tsx is there a way to change the collision type in notepad? Or is there a way to change the shapetype in godot without losing your shape?
Thanks
ZTarget
Does this plugin support Animated Tiles? Couldn't make it work here..
Import the images as Sprites and objects as StaticBodies.
There's an importing error when the tsx generated in Tiled Map Editor has not-sequential id
(possible if some entryes were deleted from an existent tileset)
The situation is easy to reproduce (test on Tiled Map Editor 2017.05.02)
-Open Tiled Map Editor
-New tileset (collection of images)
-Add 3 png tiles and save
-Then select the second tile and delete it (save again)
the tsx now is formed:
the first tile tag : tile id="0"
and the second one : tile id="2"
a map created on this tileset cannot be imported
The import operation stops with a nameless error message due this not sequential id sequence.
When using assets that are not stored in the same relative folder as the tilemap, the loader appends the entire filepath to the local path, causing an error.
Example:
TMX says image source is "D:/assets/tile.png"
TMX is stored as "C:/game/levels/level1.tmx"
The importer tries to load "C:/game/levels/D:/assets/tile.png"
how do i access custom properties?
first time i added properties to the tile itself, which i think is not suposed to work right now
next i removed those and added properties to a collision shape which i think should work?
what object do i access to get the metadata
I'm using Godot 3.0 RC1 mono build on OSX Sierra, with godot-tiled-importer cloned from this repo in the project's addons folder
The README mentions the presets (default/pixel art). I've noticed some edge artifacts in the tilesets I'm importing (gaps between solid color tiles and lines around the tiles in general that I assume are because of filter/mipmap stuff) and i want to switch to the "pixel art" preset in order to see if that addresses the issue (I've already disabled filtering and mipmaps in the project settings).
But I can't find where this is done.. the "import" tab in the editor doesn't show anything (and the "presets" button is empty). Here is what I see in the Import tab:
I can't find any settings in project settings or editor settings related to the plugin. The README doesn't say exactly where these settings are, and I'm still getting used to Godot 3.0, so if you could be more explicit about where the settings are and how you can modify them, I would be grateful.
Thanks.
Using Godot 3.0-stable and version 2.0.0 of this plugin, I can't get custom properties from Tiled into Godot. I'm using the tileset attached and importing it into Godot with the custom properties and tile metadata import options ticked. When I add a TileMap
node and set the tile_set
property to tilesetsheet.tsx
, I can access the tile_meta
dictionary from a script containing the following:
extends Node2D
func _ready():
print($TileMap.tile_set.get_meta("tile_meta"))
Attempting to do print($TileMap.tile_set.get_meta("tile_meta")[0])
gives me Invalid get index '0' (on base: 'Dictionary').
.
Hi,
This is a great plugin and I really like it.
But after I updated the plugin today, I'm getting the following error when importing tilemap, even it's a simple tilemap with just one layer. Couldn't find any clue on what happened, can you help me? Many thanks!
SCRIPT ERROR: build: Invalid get index '1' (on base: 'Dictionary').
At: res://addons/vnen.tiled_importer/tiled_map.gd:197
With Godot 3.0-stable and commit e8d89db of this plugin, the tile to be placed is located one tile above where the cursor is. This image illustrates the issue:
This bug occurs with the following Tiled tileset:
tilesetsheet.zip
Hi @vnen
There is a way to set one-way collision platform using the importer?
Hey!
Great plugin! I looked quickly through the code and found no "properties", so it seems to me that there is no "custom properties" support here yet. I saw that this one had it: https://github.com/Geequlim/godot-code/tree/master/addons/tiled_importer but that plugin didn't work for me for some reason. So, could you add support to also include the "custom properties" one can specify in Tiled?
Thanks!
Tiled has a per-map background color setting. Since it's per-map, it can't be used as the clear color in Godot.
I wonder if there's an easy way to do this in Godot that I am missing.
its goes messed in godot, all the wrong tiles in wrong positions...
i try to implement the fix of #36 but didnt work for me...
It seems not so hard to do according to this SO answer.
Some people seems to have trouble importing collision shapes. Better usage information and maybe some tutorial is needed.
A little list of things there are not well documented:
type
values for shapes and objects in an object layerOnce I import a Tiled map, how do I access properties of a layer through the Godot script? ie, accessing the height/width?
Hello. It seems like the tile indices for some tiles are off, making them appear incorrect on the map. Not sure if I'm just doing something wrong or not.
Here's a simple test tilemap and tileset.
https://www.dropbox.com/s/vpjt1cqasy7nxer/godotTiledTest.zip?dl=0
Here's also a screenshot. Right's Tiled (how it should appear), and left's Godot (how it does appear).
EDIT: Ah, I forgot to include the png file, but that's okay, I think I figured it out. The plugin assumes the tile sheet source size is a multiple of the tile size when importing. So, if you have 10x10 tiles, you have to have a tilesheet that is sized to a multiple of 10x10, and not a common power of two (i.e. I can't use a 256x256 sized tilesheet).
Due to some work in progress I had a directory structure like this:
+ game-root
- campaigns
- test_campaign # Original test files
- test_campaign.tmx
- test_campaign.tsx
- test_campaign.png
- assets # "Production" assets, mid-organization of directory structure
- test_campaign
- new_campaign_assets.tsx # Used by test_campaign.tmx
- new_campaign_assets.png # Used by new_campaign_assets.tsx
However, the importer can't find "new_campaign_assets.png" because it's checking /game-root/campaigns/test_campaign
. I think this is because options.basedir is, and when a .tsx and its .png file are side-by-side there's no absolute path involved, just a relative one.
Hello,
I've defined collisions masks in my Tiled file.
When there are defined as rectangles or circles, they are imported (circles are transformed to capsules, as you warn in your ReadMe).
But when they are either polygon or polyline, they are not imported properly. I tried to draw them in clockwise order, as you mention it in the documentation.
I've made a super simple project for showing this:
http://www.fileconvoy.com/dfl.php?id=gce45a38560766ea09999213823bd8b15150eb6388
(password is godotgodot)
In the project above, collisions defined with rectangles are imported in Godot (horizontal and vertical road tiles).
You can see a screenshot of a collision not exported here:
http://tof.canardpc.com/view/2300dbe5-c12d-422a-912d-007cd6702fcc.jpg
(this is a screenshot of the tmx file provided in the archive above).
Thank you!
Currently, this plugin is only available in the AssetLib for Godot2. Can we get the latest version tagged for Godot3 in the AssetLib?
Two ways that this can be done:
The first is more taxing to the game while the second is more taxing to the import process. Replacing pixels is a slow procedure (OTOH it needs to be done only when (re)importing).
I have a Tiled map whose tile width / height is 32x32.
However, I have a tileset that's a collection of images, with some images larger than 32x32 -- 64x64 or higher[0]. The add-on won't import them because of this check:
I've been exporting to .tmx format, if that helps.
[0] The kind of Tileset that gets generated when you do this: File -> New -> New Tileset, select "Type: Collection of Images". This kind of Tileset lets you mix and match without having to rely on a single huge tilesheet.
Hi,
I'm able to edit but no longer import new Tiled maps using Godot 3, as the import functionality has radically changed.
Is there a way to import now without importing into Godot 2 and exporting the scene?
Thanks.
It's possible in Tiled to make a TileSet from multiple images so each tile reference a different image. Right now the importer only recognizes single image TileSets.
Post-import contains only "return string"
In output of editor next error appears:
res://addons/vnen.tiled_importer/tiled_importer_plugin.gd:101 - Invalid call. Nonexistent function 'new' in base 'GDScript'.
Using Godot stable 2.1.3. Stopped to work unexpectedly (before certain moment with post-import script was possible)
I've been testing this plugin and it works great. I noticed that Godot does a brief pause and re-imports almost each time I focus the editor window - even though I didn't change the source files. The auto-reload is great in itself, but when it happens often the lag is just enough to annoy ๐
I was wondering if this is a Godot-engine-related thing
Currently using v2.1.2-stable (through Steam) on Windows 10
I made some pretty big edits to my tilesheet in order to use Tiled's awesome Terrain Tool. Mainly lots of moving tiles around in the .png
.
However, it seems like the importer didn't re-import my tilesheet image -- so the map came out looking insane. I opened up the generated .scn file in Godot, and glanced through its Tilemaps, and it was obvious it was using an old (cached?) version of the the tilesheet.
Importing the .tmx
file and saving it into a new scene works perfectly fine, though.
I tried write post_import script and and looks like:
func post_import(scene):
# Load scenes to instantiate and add to the level
# The scene variable contains the nodes as you see them in the editor.
# scene itself points to the top node. Its children are the tile and object layers.
for node in scene.get_children():
# To know the type of a node, check if it is an instance of a base class
# The addon imports tile layers as TileMap nodes and object layers as Node2D
if node extends TileMap:
# Process tile layers. E.g. read the ID of the individual tiles and
# replace them with random variations, or instantiate scenes on top of them
pass
if node extends Node2D:
for object in node.get_children():
var name = object.get_name()
print("ENTITY NAME: "+name)
var metalist = object.get_meta_list()
for item in metalist:
print(str(item))
if object.has_meta("type"):
var type = object.get_meta("type")
print(" TYPE: "+type)
# You must return the modified scene
return scene
Find an algorithm to sort the points in clockwise order. Add an option to avoid the overhead this might cause.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.