I am trying to load a random object from a list. What I have doesn’t work. I could use a case statement but eventually stuff will be a huge list that is called often. Is there a better way to do this?
var aaa = preload(“res://src/aaa.tscn”)
var bbb = preload(“res://src/bbb.tscn”)
var ccc = preload(“res://src/ccc.tscn”)
var stuff = [ “aaa”, “bbb”, “ccc” ]
_process(delta) {
var selected = str(stuff[(randi_range(0, 2)])
var new_thing = selected.instantiate()
add_child(new_thing)
new_thing.global_position = Vector2(10,10)
}