#Setting cells in a tilemap

1 messages · Page 1 of 1 (latest)

short crag
#

It seem that i'm having issue with setting a cell on a tilemap.

For some obscure reasons, godot doesn't seem to be setting the cell to the specified tile on the tileset (which i assume to be the atlas).

var castedPosition = terrain.LocalToMap(node.Position);

// also add an invisible tile to the tilemap
terrain.SetCell(2, castedPosition, 0, placeHolderAtlasCoords);

var atlasCoords = terrain.GetCellAtlasCoords(1, castedPosition);

var unitTile = terrain.GetCellTileData(2, castedPosition);
unitTile.SetCustomData("Units", node);
var customDataRes = unitTile.GetCustomData("Units");
var unitAsCustomData = customDataRes.As<Unit>();

where placeHolderAtlasCoords = <0,4> as it would be indicated in the tileset editor (see the image).

after setting the cell, i'm checking its tile atlasCoords to make sure it's the same but apparently, it is equal to <-1, -1> which is, an invalid tile.

As a result, the rest of the operation fails.

Why is it failing to set the tile?

PS: My TileMap terrain does have a layer named Units, its index is indeed 2 (3rd layer) & my tileset indeed has an ID of 0 in the editor.

short crag
#

Still haven't found a solution, i tried <0,0> as atlas coords and still is considered invalid

short crag
#

guess i will just not make use of layers for that and just use some matrixes instead

cloud fractal
#

You're setting a tile in layer 2, then checking the atlas coords of the tile in layer 1.

short crag
#

still <-1, -1>

#

and ofc, my custom data still is null somehow