mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
Randomize RandomNumberGenerator instances' default seed
This commit is contained in:
parent
18177828ad
commit
a871114339
@ -57,7 +57,7 @@ public:
|
||||
_FORCE_INLINE_ real_t randfn(real_t p_mean = 0.0, real_t p_deviation = 1.0) { return randbase.randfn(p_mean, p_deviation); }
|
||||
_FORCE_INLINE_ int randi_range(int p_from, int p_to) { return randbase.random(p_from, p_to); }
|
||||
|
||||
RandomNumberGenerator() {}
|
||||
RandomNumberGenerator() { randbase.randomize(); }
|
||||
};
|
||||
|
||||
#endif // RANDOM_NUMBER_GENERATOR_H
|
||||
|
@ -10,10 +10,9 @@
|
||||
[codeblock]
|
||||
var rng = RandomNumberGenerator.new()
|
||||
func _ready():
|
||||
rng.randomize()
|
||||
var my_random_number = rng.randf_range(-10.0, 10.0)
|
||||
[/codeblock]
|
||||
[b]Note:[/b] The default values of [member seed] and [member state] properties are pseudo-random, and changes when calling [method randomize]. The [code]0[/code] value documented here is a placeholder, and not the actual default seed.
|
||||
[b]Note:[/b] The default values of [member seed] and [member state] properties are pseudo-random, and change when calling [method randomize]. The [code]0[/code] value documented here is a placeholder, and not the actual default seed.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="Random number generation">$DOCS_URL/tutorials/math/random_number_generation.html</link>
|
||||
|
Loading…
Reference in New Issue
Block a user