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

Flipped tiles aren't imported correctly

Open vnen opened this issue 7 years ago • 10 comments

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.

vnen avatar Dec 06 '17 18:12 vnen

This is worked around on master, should port to 1.x.

vnen avatar Jan 25 '18 01:01 vnen

Tiles are rotated, but collision on tiles are still not rotated correctly when imported into godot

fossegutten avatar May 31 '18 17:05 fossegutten

I still have an issue when importing flipped/rotated tiles, collision shape is shifted ("upward" of the original tile) and it happens even with tiles with no collision shape. Dunno if this is know or not. rotation_flip_bug

HephepTeam avatar Aug 19 '18 19:08 HephepTeam

I'll have to check this. If there are sample projects for me to test would be nice to post here.

vnen avatar Aug 19 '18 20:08 vnen

Hope I did it right and it can help, here is the sample project : Tiled_import_test.zip

Grid is 256*256 and tiles above this size when flipped or rotated are moved by the height of the tiles. I don't know how but if you can de-zoom the default view (didn't try as I have a camera2D attached to my player in my main project) and show the collision shape you will see that a simple white block that I rotated has his collision shape shifted but not the image.

HephepTeam avatar Aug 19 '18 20:08 HephepTeam

Tiles are rotated, but collision on tiles are still not rotated correctly when imported into godot

For anyone facing this I've found a workaround. While defining tiles' collisions, use the Polygon Tool instead of the Rectangle Tool.

Don't forget to close the loop (clicking on the first vertice) and press Enter after defining each one of them.

diegomachado avatar Oct 15 '18 14:10 diegomachado

Thanks Diego 👍

fossegutten avatar Oct 18 '18 16:10 fossegutten

That work around didn't seem to do anything. This issue still exists in Godot 3.1. It happens when it's flipped or rotated in the Y. Flipping or rotating in the X is fine. The offset is off by a full two tiles. Maybe it has something to do with the collision's pivot?

Here is a test project: Tiled_Flip_Collision_Bug.zip

tiled_flip_collider_bug

svendixon avatar Apr 24 '19 03:04 svendixon

Heres the work around that worked for me. go into tiled in your .tsx tab 1 select a tile that has this problem and then go to the collision editor window
2 use the select object button and highlight your collision shape (there should be a bouncing box at this point) 3 Look in the property section under object then look at the X and Y values these have to be zero to work 4 Set them to zero (this will move the shape away from where it should be) 5 Now back in the Collision editor window select the edit polygons button and drag over the whole shape and move it back to where it belongs.

(you can verify that X and Y are zero still by repeating step 2) Thats it, remember to save the tsx and the map and reimport both to get it to show up in godot This seems to only work for polygons. rectangles either work or don't work in my project so im just going to change those to polygons for now.

I also noticed in godot if you select the tile layer in the scene window and and go to cell then tile origin and change it to top left the collision seems to line up with the map correctly but then the map get messed up --may be a clue for figuring out the bug

ZTarget avatar Jun 09 '19 07:06 ZTarget

Yeah, there's something weird going on with rotated tiles and per-tile collisions for me as well. Seems like neither polygons nor rectangles are properly placing the collisions in 100% of the cases.

It seems like it might be best to define collisions on the object layer of the tile map rather than using per-tile collisions for now.

SolarLune avatar Jun 17 '19 22:06 SolarLune