Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 4K4deusz | |
Old Version | Published before Godot 3 was released. |
Hello,
I am trying to make build a random generator, so that a deck of cards will be randomized every time you start the scene. I am new to scripting and could do with some pointers or simple examples.
so far I got this working:
extends GridContainer
var RandomNumber = randi()%11
func _ready():
print (RandomNumber)
but it only prints the same number every time. I get the feeling I have to use seed() but not sure how to do that. The docs mentions:
Array rand_seed( int seed )
Random from seed, pass a seed and an array with both number and new seed is returned.
float randf()
Random value (0 to 1 float).
int randi()
Random 32 bits value (integer). To obtain a value from 0 to N, you can use remainder, like (for random from 0 to 19): randi() % 20.
Nil randomize()
Reset the seed of the random number generator with a new, different one.
Any help/explanation would be appreciated.
Thanks
4k4deusz