Random Number generates the same float every time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Irrelevant Person

I have this problem often at programming. Does someone has a solution for the problem, that although the var is generated with a random functions, it generates the same at start of game?

:bust_in_silhouette: Reply From: jgodfrey

Assuming you’re using the RandomNumberGenerator object, you just need to call its Randomize() function (once) prior to using it. Something like this:

var rng = RandomNumberGenerator.new()
func _ready():
    rng.randomize()
    print(rng.randi())

thx, now it works :smiley:

Irrelevant Person | 2020-03-14 22:28