GithubHelp home page GithubHelp logo

vnen / godot-tiled-importer Goto Github PK

View Code? Open in Web Editor NEW
794.0 26.0 84.0 279 KB

Plugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets

License: MIT License

GDScript 100.00%
godot-engine tilemap tiled tilesets godot gdscript

godot-tiled-importer's Introduction

George Marques

Hello! I'm George Marques, also known as vnen or xoshy around the web.

Summary

  • ๐Ÿ‡ง๐Ÿ‡ท Living in Sรฃo Paulo
  • ๐Ÿ—ฃ๏ธ Speaks Portuguese and English
  • ๐Ÿ’ป Programmer by trade
  • ๐ŸŽธ Guitarist by hobby
  • โœ๏ธ Likes to write stuff sometimes

More about me

I'm a software engineer based on Sรฃo Paulo - Brazil. Currently I'm the CEO of Vertex Ludi, a company that offers support and consulting for Godot Engine users, and I'm also working for the Godot Engine project itself as the maintainer of GDScript (their custom scripting language).

I learned programming when I was about 7 years old by drawing with Basic in a 386 computer with MS-DOS, after my brother taught me. Also playing a bit with DBase in the very same computer. Over time I got to learn some other things by myself, like Visual Basic, Delphi, Web stuff like HTML, JavaScript, VBScript (that was thing), ASP (not ASP.Net), PHP, and the list goes on. Jack of all trades master of none.

Games were always a bit of a passion of mine and I enjoy making stuff more than playing games. Though I'm the worst to have game ideas so I never really did anything besides clones for fun (or started huge story-driven projects that stopped not far from the beginning). Nowadays I work indirectly with games by coding for the Godot Engine.

If you know me from Godot, I'm also helping with GDExtension (the API for native dynamic modules), besides working here and there with other engine areas.

I also play the guitar (not very well) as a hobby and I like to write fiction when the mood strikes.

Knowledge & technologies

In no particular order.

  • C++
  • C
  • Godot/GDScript
  • TypeScript
  • JavaScript
  • Swift (learning)
  • Android
  • iOS (learning)
  • HTML5
  • CSS
  • Bootstrap
  • Node.js
  • Express
  • Linux
  • Bash
  • Arduino
  • MySQL
  • Docker
  • Vim (how to exit)

Also can dabble in:

  • PHP
  • WordPress (Themes/Plugins)
  • Python
  • Rust
  • Haskell
  • OCaml

godot-tiled-importer's People

Contributors

aaronsnoswell avatar cmfcmf avatar elouataoui avatar giraugh avatar jakes1403 avatar jonathlela avatar matt-c-lane avatar olivergs avatar olsonjeffery avatar radicaled avatar rosshadden avatar shinaka avatar sirramesq avatar sleepprogger avatar tubeliar avatar univeous avatar vnen avatar wildos 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot-tiled-importer's Issues

Provide a sample tmx file for rerefence

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.

Importer seems to not update tilesheet images when re-importing.

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.

Custom property doesn't appear as metadata

Hello,

I'm trying to import a map with an object which contain a custom property:

image

I check the checkbox is check in the import window

image

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 ?

Import issues

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.

noob need help with custom properties

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

Need help, keep getting same error when importing tilemap

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

Support for post-import script

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.

Map background color

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.

Can import .tmx file into godot:

returns, this error msg:
res://addons/vnen.tiled_importer/tiled_map.gd:169 - Invalid operands 'int' and 'String' in operator '+'

polygon shape is hollow

i created a polygon shape in tiled for collision.
when i import to godot only the lines appear(show collision debugger option) and the player will fall thru them

godottiledbug

Relative image loading doesn't work if not nested in .tmx file in directory hierarchy.

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.

Imported tile indices are off

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).

screenie

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).

Re-import / lag each time Godot window is re-focused (Windows)

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

Importing map causes some tiles to be blank or other tiles

When I Import a simple map, some of the tiles are replaced with other tiles or left blank.

Looking at the tileset in the godot editor it seems all the tiles are created properly, but the actual tileset ends up with random tiles on the map or a empty tile.

tiled view

in-godot

ability to specify object shapes that come over as arbitrary Area2Ds

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).

Animated Tiles

Does this plugin support Animated Tiles? Couldn't make it work here..

Concave collision not working?

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

Type doesn't exist ...

I tried write post_import script and and looks like:

  1. when is defined type in objecttypes.xml and values are not changed, then are properties empty
  2. object.has_meta("type") is always empty/doesn't exist.

Traverse the node tree and replace Tiled objects

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

Not compatible with Godot 3.0b

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.

tile_meta Dictionary Not Populated with Custom Properties

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')..

tilesetsheet.zip

Support for image collection tilesets

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.

Can't import Tilemaps that have TileSets with different sizes.

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:

if (width and height) and (image.get_width() != width or image.get_height() != height):

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.

Document importing features

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:

  • The imported scene should not be edited directly (use inheritance or instancing)
  • How to create collision/navigation/occluder shapes (cf. #18 (comment))
  • How to set up custom properties and read the metadata in Godot
  • The possible type values for shapes and objects in an object layer
  • Post-import script usage (cf. #29)

Loading image from non-relative directory fails

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"

Add 3.0 branch to Asset Lib

Currently, this plugin is only available in the AssetLib for Godot2. Can we get the latest version tagged for Godot3 in the AssetLib?

Seeing edge artifacts in pixel art tiles; How to access/change import settings for tiled import plugin?

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:
screen shot 2018-01-21 at 10 23 54 am

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.

Collisions masks are not always imported

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!

tile_meta doesn't exist?

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?

Flipped tiles aren't imported correctly

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.

Post_import function: scene is not affected by my modification

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 ?

Support for transparent colors

Two ways that this can be done:

  1. Leave the original image like it is and use a shader to replace the pixels.
  2. Read the every pixel from the image data and replace it by a transparent one.

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).

Can't import with post-import script (Misleading error messages).

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)

"Invalid GID" error when an object doesn't have GID set.

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

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.