4.2.2
I’m using a script to place random tiles from my own Tileset onto a hex grid. However, when I run the script, it seems gray tiles are being placed instead of my own custom tiles. I have made sure the IDs match, that I can manually place the tiles, and my camera is working correctly. I’m sure it’s something obvious I’m missing, but I can’t seem to see my own tiles when I run my code, only gray tiles.
Thank you.
Here’s my code:
extends TileMap
const TILE_IDS = [8 ,9 ,10]
func _ready():
randomize()
generate_random_tilemap()
func generate_random_tilemap():
var map_width = 10
var map_height = 10
for x in range(map_width):
for y in range(map_height):
var random_tile = TILE_IDS[randi() % TILE_IDS.size()]
var tile_position = Vector2i(x, y)
set_cell(0, tile_position, random_tile, Vector2i(-1, -1))
print("Placing tile ID:", random_tile, "at position:", tile_position)