godot-LDtk-import
godot-LDtk-import copied to clipboard
'Rectangle of tiles' doesn't import properly
Unsure if limitation or user error, but marking an area of tiles in either an Intgrid or Autotile layer fails to import appropriately into Godot.
It behaves appropriately in editor but doesn't seem to in the generated scene.
LDTK
Godot
Using Godot 3.5 Stable with LDtk 1.1.3-64bit
Minimal recreation: The 'AutoLayers 2 stamps' sample map in LDtk uses a 2x2 rectangle of tiles rule in its Intgrid layer.
I'm also having the exact same issue...
I've located and fixed the issue - just working up a pull request :)
I am not able to push up a new branch and not sure of the best way to help... I assume that the repository is locked down, which is understandable... my diff is pretty simple:
/addons/LDtk-Importer/LDtk.gd
func new_tilemap(tilemap_data):
var flip = int(tile["f"])
var flipX = bool(flip & 1)
var flipY = bool(flip & 2)
var grid_coords = pxCoords_to_gridCoords(tile.px, tilemap_data.__gridSize)
tilemap.set_cellv(grid_coords, tile.t, flipX, flipY)
return tilemap
#converts pixels to grid coordinates.
func pxCoords_to_gridCoords(pixelValues, gridSize):
var gridY = floor(pixelValues[1] / gridSize)
var gridX = floor(pixelValues[0] / gridSize)
return Vector2(gridX, gridY)
Basically it looks like LDtk references the same tile within the "d" attribute multiple times when a rectangle shape is defined. Consequently the tile is overwritten and will only display the last shape in the applied rectangle. I created a grid coord function to take the pixel value instead, which is accurate, and update the tile based on that.
Think I've worked out how to actually contribute!