There's no reason that calling randi()
from a timer should cause the same number to be generated each time. You will get the same series of random numbers each time you run the scene, but that's generally not a problem. And, you can fix that by calling randomize()
one time after the scene loads (say, in _ready
).
For example, this (wired to a Timer's
timeout
event) outputs a different number with each call:
func _on_Timer_timeout():
var val = randi() % 300
print(val)
I don't really understand your spawing logic though. I'm not sure why you go to the trouble of setting 3 different variables (b, c, and d) based on a random number, but then execute (a copy of) the same code for each of them.
I'm confident that your spawn code can be simplified, but you probably need to better explain what you want the spawner to do...