<aside> 💡

This page assumes you know the different Godot RNG-related concepts as written in the Godot documentation. In particular, seeds and states, the seed() and randomize() functions and the RandomNumberGenerator class.

</aside>

☄️Seed Management

<aside> ⚠️

From the 4.7.1, BuH uses a RandomNumberGenerator stored in the variable Spawning.RAND that has Spawning.RAND_SEED as seed. In pre-4.7.1, BuH uses the global RandomNumberGenerator.

Also note that the way the global RNG is handled has changed from Godot 3 to Godot 4 : Since Godot 4.0, the random seed is automatically set to a random value when the project starts. This means you don't need to call randomize() in _ready() anymore to ensure that results are random across project runs. This method should be called only once when your project starts to initialize the random seed. Calling it multiple times is unnecessary and may impact performance negatively.
For this reason, BuH 4.7.1 uses its own RNG and randomize() calls in nodes have been removed.

If you just want to add some randomness to the properties, you don’t have to understand how it all works but if you want to control the RNG, you should understand this post : https://stackoverflow.com/questions/79434187/does-random-seeding-change-the-project-globally-or-at-the-scene-tree-level

</aside>

The plugin allows you to set the seed of the plugin’s RNG (see RAND_SEED and Randomisation. This seed will only impact the plugin and not the rest of the game. Everything random in the plugin will inherit this RNG.

If no seed is set (RAND_SEED = -1), a random one will be generated with RAND.randomize().

You can also use a RNG you created. For example, if you want your entire game to use the same RNG. Use rng_setup and pass your RNG as an argument. Unfortunately, from what I know, Godot doesn’t allow you to get a reference to its global RNG.

Random properties

<aside> 💡 Warning : using randomisation in resources will impact memory usage as explained in Randomisation : why it’s a mess

</aside>

Some of the nodes / resources have a “random” category with properties which allows you to randomize all the properties mentioned above. This is how to use them :