0 votes

Why should I use RandomNumberGenerator instead of randi() or randf() etc.?

Godot version 3.2.3.stable
in Engine by (380 points)

1 Answer

+1 vote
Best answer

Both the procedural (global scope) and object-oriented (RandomNumberGenerator) approaches work the same way. That said, RandomNumberGenerator lets you use different seeds for different instances, therefore giving you more control over determinism (or lack thereof).

There is no "better" approach, but if you don't care about being able to use different random seeds at the same time in your project, the procedural (global scope) approach will require less code to get things done.

by (11,893 points)
edited by
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 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 webmaster@godotengine.org with your username.