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.