Browse Source

:beetle: Fix spawning balls even when processing disabled

Timers created by script where living out of the node process ; so using
a timer node solves the issue.
DricomDragon 1 week ago
parent
commit
1882b1d388

+ 0 - 3
godot/slides/204/physics_demo/Spawner.gd

@@ -3,7 +3,6 @@ extends Node2D
 var BallScene: PackedScene = preload("res://slides/204/physics_demo/Ball.tscn")
 
 @export var dispersion_scale : Vector2 = Vector2.ONE
-@export var delay := 1.0
 
 
 func _ready():
@@ -17,8 +16,6 @@ func spawn():
 
 	add_child(ball)
 
-	get_tree().create_timer(delay).connect("timeout", _on_delay_time_out)
-
 
 func _on_delay_time_out():
 	spawn()

+ 7 - 1
godot/slides/204/physics_demo/physics_demo.tscn

@@ -27,4 +27,10 @@ position = Vector2(760, 728)
 position = Vector2(906, 239)
 script = ExtResource("2_tlo74")
 dispersion_scale = Vector2(80, 40)
-delay = 0.25
+
+[node name="SpawnInterval" type="Timer" parent="."]
+process_callback = 0
+wait_time = 0.3
+autostart = true
+
+[connection signal="timeout" from="SpawnInterval" to="Spawner" method="_on_delay_time_out"]