repeat random number fix

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

round(rand_range()) randi() or rand_range()
repear number

ex: rand_range (10,15))
print(rand_range)
10 12 15

turn of the program and turn on
print:
10 12 15

repear number

How to fix

:bust_in_silhouette: Reply From: kidscancode

You need to call randomize() at run time to seed the random number generator.

:bust_in_silhouette: Reply From: ibo348

func _ready():
randomize()

I used it but it not worked

I see you’re running the scene, did you put randomize() in that scene’s script? Otherwise it’s really hard to help you without more information about what you’re doing.

This:

extends Node

func _ready():
    randomize()
    for i in range(3):
        print(int(rand_range(10, 15)))

works fine here and produces a different sequence of numbers each run.

kidscancode | 2018-01-31 22:57

thanks bro

ibo348 | 2018-02-02 13:35