Hi all. Sorry if this was asked before.
I am trying to instance mob scenes from arrays randomly but even with randomize() and randi, they can some times still instance the same one many, many times in a row.
Is there a way to truly randomise instances without it repeating the previous var and without removing it from the array?
This is an example of my own attempt with the shuffle() method but it didn't work. Any advice would be greatly appreciated!
# One of my many mob arrays.
var spawnable_a = [mobs_a3, mobs_a4, mobs_a5, mobs_a6, mobs_a7, mobs_a8]
var spawnable_a_full = []
func _ready():
randomize()
spawnable_a_full = spawnable_a.duplicate()
spawnable_a.shuffle()
func _on_Timer_A_timeout():
if spawnable_a.empty():
spawnable_a_full = spawnable_a.duplicate()
spawnable_a.shuffle()
if score <= 19:
var spawn = spawnable_a[randi()%spawnable_a.size()].instance()
call_deferred("add_child", spawn)
$Timer_A.start()