-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically call randomize()
in GDScript upon running a project
#1774
Comments
I know this is done for the purposes of debugging games -- it makes it easier to replicate results. That said, I wouldn't be against this being a Project Setting. It seems like a fairly reasonable setting to add. |
I agree because the RNG in Godot is not the only one out there, and other implementations can reuse the same project setting (in plugins and modules). But I know for sure that Godot is allergic to adding potentially "specific" settings, so I'd be personally happy with any decision. But one also have to take into account the amount of confusion this currently creates for beginners. 🙂 The new setting could be added in |
randomize()
implicitly for true randomness in GDScriptrandomize()
for true randomness in GDScript
randomize()
for true randomness in GDScriptrandomize()
for true randomness in GDScript upon running a project
I think we should always do this. There's no need to add a project setting. For people who need determinism, they can create their own RandomNumberGenerator instance and set the seed manually. |
You don't even need RandomNumberGenerator, just call |
randomize()
for true randomness in GDScript upon running a projectrandomize()
in GDScript upon running a project
Describe the project you are working on:
Godot Engine.
Describe the problem or limitation you are having in your project:
I don't, but users do:
I can likely find a bunch of other examples.
I recall stumbling upon the same limitation when I first started using the engine (like 4 years ago), with mostly lack of programming experience. So, I think this is mostly confusing to beginners.
See also #1590:
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Call
randomize()
in the engine automatically for global RNG, so this is mostly about GDScript and built-inMath::random()
usages in the engine. This should not affect local instances ofRandomNumberGenerator
classes.Tests in C++ should use
RandomNumberGenerator
locally instantiated for reproducible random results (for stress tests), and of course in GDScript for similar use cases if you do need to control the seed, like procedural generation.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
It's a matter of calling
randomize()
somewhere in the engine. This breaks compatibility, but it's the perfect time for Godot 4.0.If this enhancement will not be used often, can it be worked around with a few lines of script?:
Sure, just call
randomize()
in GDScript.Is there a reason why this should be core and not an add-on in the asset library?:
Already part of core.
The text was updated successfully, but these errors were encountered: