Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Honno |
Hello fine folks, I need some assistance—basically I want place autotiles that are over/under-lapped by other tiles, like so Imgur: The magic of the Internet . In this example I want the three textures to have different z-indexes, hence need for different sprites.
I first thought to create a tileset with 3 textures and each define the respective tiles with the same bitmask, then I’d use a custom node to let the user define the main tileset to be used and additional tilesets to overlap (would define the z-indexes for each texture). Like so:
tool
extends TileMap
# Resource ID of main tileset
export(int) var main_tileset_id = 0
# Offset of each tileset (resource ID: int <-> offset: Vector2)
export(Dictionary) var tileset_offsets
func _enter_tree():
var overlapping_tilemaps = Dictionary()
for resource_id in tileset_offsets.keys():
var overlapping_tilemap = TileMap.new()
var pixels_offset = tileset_offsets[resource_id] * cell_size
overlapping_tilemap.translate(pixels_offset)
overlapping_tilemap.cell_size = cell_size
overlapping_tilemap.tile_set = tile_set
overlapping_tilemaps[resource_id] = overlapping_tilemap
for cell in get_used_cells():
???
NB: offset is where to place an over/underlap tile respective to the main one, like Vector2(0,-1)
for a tile above.
But it doesn’t seem theres a way to find the bitmask value of a placed tile in a TileMap, i.e. I can get_used_cells()
to get all the positions of placed cells, and get_cellv(pos)
to get the cells id, but is there some way to get the bitmask value or the .tres
bitmask vector used for that specific cell? I can set them just fine apparently with set_cell
taking an autotile_coord
.tres
vector value, its just getting the bitmask value/.tres
vector (converting a bitmask value to the vector value whould be doable messing with the .tres
file).
I suppose the TileMap doesn’t actually hold the value of the bitmask, and it’s the editor thats doing the autotiling, which is fair enough. So I was wondering if there’s a nice solution I haven’t thought of to achieve this “automatic overlapping of autotiles”?
I would like this process automated coz I’ll be doing it a lot (it’s achievable if you create a script that defines dictionaries of a single tile ID and all the respective overlap tiles, but that doesn’t take advantage of autotile which I really do need).
Please ask any further questions if needed! Thanks for your time~