Merge pull request #30101 from tree786/patch-1

Added example on how to use RandomNumberGenerator
This commit is contained in:
Rémi Verschelde 2019-06-30 22:02:41 +02:00 committed by GitHub
commit 495fedca55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,13 @@
<description>
RandomNumberGenerator is a class for generating pseudo-random numbers. It currently uses [url=http://www.pcg-random.org/]PCG32[/url].
[b]Note:[/b] The underlying algorithm is an implementation detail. As a result, it should not be depended upon for reproducible random streams across Godot versions.
To generate a random float number (within a given range) based on a time-dependant seed:
[codeblock]
var rng = RandomNumberGenerator.new()
func _ready():
rng.randomize()
var my_random_number = rng.randf_range(-10.0, 10.0)
[/codeblock]
</description>
<tutorials>
</tutorials>