Godot v4.4.1
Question
I am making a survival game platformer style, and I wanted ores to spawn randomly above specific dirt, moss and sand tiles. They will spawn at different probabilities. I need them to check if there is no tile above that tile, and then instantiate to spawn an ore there. I am a bit confused on how to do this though, this is my progress so far:
extends Node
@export var terrain_layer := 0
@export var spawn_parent: NodePath
@export var total_ores = 30
@onready var tilemap = $“../Terrain/TileMapLayer”
const valid_tile_ids = [0, 1, 3]
var ore_scenes := {
“granite” : preload(“res://Scenes/Ores/granite.tscn”),
“obsidian” : preload(“res://Scenes/Ores/obsidian.tscn”),
“quartz” : preload(“res://Scenes/Ores/quartz.tscn”),
“amethyst” : preload(“res://Scenes/Ores/amethyst.tscn”),
“ruby” : preload(“res://Scenes/Ores/ruby.tscn”)
}
var spawn_weights := {
“granite” : 0.52,
“obsidian”: 0.3,
“quartz” : 0.12,
“amethyst” : 0.05,
“ruby” : 0.01
}