瀏覽代碼

Merge pull request #43330 from KoBeWi/rngesus

Call randomize() automatically
Rémi Verschelde 4 年之前
父節點
當前提交
492b8aa9a5
共有 2 個文件被更改,包括 3 次插入4 次删除
  1. 1 4
      doc/classes/@GlobalScope.xml
  2. 2 0
      scene/main/scene_tree.cpp

+ 1 - 4
doc/classes/@GlobalScope.xml

@@ -804,10 +804,7 @@
 		<method name="randomize">
 			<description>
 				Randomizes the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
-				[codeblock]
-				func _ready():
-				    randomize()
-				[/codeblock]
+				[b]Note:[/b] This method is called automatically when the project is run. If you need to fix the seed to have reproducible results, use [method seed] to initialize the random number generator.
 			</description>
 		</method>
 		<method name="range_lerp">

+ 2 - 0
scene/main/scene_tree.cpp

@@ -1349,6 +1349,8 @@ SceneTree::SceneTree() {
 
 	GLOBAL_DEF("debug/shapes/collision/draw_2d_outlines", true);
 
+	Math::randomize();
+
 	// Create with mainloop.
 
 	root = memnew(Window);