Godot Version
newest version
Question
It just returns blank, maybe the set_cell isnt being used properly?
extends TileMap
@export var noise = FastNoiseLite.new()
@export var tileset : TileSet
@export var width : int = 10
@export var height : int = 10
@export var threshold1 : float = 0.3
@export var threshold2 : float = 0.6
@export var grassTile : int = 0
@export var grassWithFlowersTile : int = 1
@export var otherTile : int = 2
func _ready():
generate_map()
func generate_map():
noise.seed = randi()
for x in range(width):
for y in range(height):
var noise_value = noise.get_noise_2d(x,y)
var tile_index = map_noise_to_tile_index(noise_value)
var index = y * width + x
var coords = Vector2i(x, y)
set_cell(0, coords, -1, Vector2i(-1, -1), tile_index)
func map_noise_to_tile_index(value):
if value < threshold1:
return grassTile
elif value < threshold2:
return grassWithFlowersTile
else:
return otherTile