Godot Version
4.3.dev3
Question
I have a wang terrain set with this bitmask:
When I paint this terrain onto the TileMap it works just as expected.
But when I try to achieve the same result using tile_map.set_cells_terrain_connect
it does not work.
For some reason, I have to include the neighbor cells to get the same result as in the editor.
func _generate():
tile_map.clear()
var cells := {}
for x in 10:
cells[Vector2i(x, 0)] = null
tile_map.set_cells_terrain_connect(0, cells.keys(), 0, 0) # nothing happens
func _generate():
tile_map.clear()
const NEIGHBORS := [
Vector2i.LEFT,
Vector2i.RIGHT,
Vector2i.UP,
Vector2i.DOWN,
Vector2i(-1, -1),
Vector2i(-1, 1),
Vector2i(1, -1),
Vector2i(1, 1)
]
var cells := {}
for x in 10:
cells[Vector2i(x, 0)] = null
for neighbor in NEIGHBORS:
cells[Vector2i(x, 0) + neighbor] = null
tile_map.set_cells_terrain_connect(0, cells.keys(), 0, 0) # the tiles get drawn
It gets really funky when I try to add cells in the y direction. The code below leads to this tilemap.
I have no clue where the tile in the red rectangle comes from.
func _generate():
tile_map.clear()
const NEIGHBORS := [
Vector2i.LEFT,
Vector2i.RIGHT,
Vector2i.UP,
Vector2i.DOWN,
Vector2i(-1, -1),
Vector2i(-1, 1),
Vector2i(1, -1),
Vector2i(1, 1)
]
var cells := {}
for x in 10:
cells[Vector2i(x, 0)] = null
for neighbor in NEIGHBORS:
cells[Vector2i(x, 0) + neighbor] = null
for y in 10:
cells[Vector2i(0, y)] = null
for neighbor in NEIGHBORS:
cells[Vector2i(0, y) + neighbor] = null
tile_map.set_cells_terrain_connect(0, cells.keys(), 0, 0)
I have tried using both dictionaries and arrays for this. Neither work for the terrain set. The code is correct though. When I use this code it works as expected.
for cell in cells:
tile_map.set_cell(1, cell, 0, Vector2i(1, 1))
Is there something wrong with my bitmask or what am I missing here?