The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I want to create a random dungeon generation, and I noticed that randi(), rand_range() and randi_range() always return the same numbers. For example: if I use var x = randi() % 15 it's always return a 8.
I had used randomize() before this in _ready() function. And I have Ubuntu 21.04

Godot version 3.3.2.stable.official
in Engine by (12 points)

Godot version 3.2.2.stable.official

Godot 3.2.x is not supported anymore. Please upgrade to 3.3.2 :)

I had updated to 3.3.2 and problem is still

var rng =

func _ready():
    for i in range(10):
        var _x = randi() % 15

Everytime different number. Godot 3.3.2

I created a test project, added a node 2d and paste your code. Every time I run the program I have the same numbers:14, 0, 12, 0, 4,12, 8, 3, 3, 2
Maybe it's problem with my Ubuntu?

var _x = rng.randi() % 15

Instead of

var _x = randi() % 15

My mistake

it helped, thanks!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.