From 128eaa2718834e3ea68933e883121c49e5397bc2 Mon Sep 17 00:00:00 2001 From: tree786 Date: Sat, 29 Jun 2019 22:59:22 +0100 Subject: [PATCH] Added example on how to use RandomNumberGenerator (cherry picked from commit 68c6790baf84d479faef0a344cd151ea95776c0a) --- doc/classes/RandomNumberGenerator.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/classes/RandomNumberGenerator.xml b/doc/classes/RandomNumberGenerator.xml index 6c645468256..33727be0acf 100644 --- a/doc/classes/RandomNumberGenerator.xml +++ b/doc/classes/RandomNumberGenerator.xml @@ -4,7 +4,15 @@ A class for generating pseudo-random numbers. - RandomNumberGenerator is a class for generating pseudo-random numbers. It currently uses PCG32. The underlying algorithm is an implementation detail. As a result, it should not be depended upon for reproducible random streams across Godot versions. + 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]