Weird behavior of the Timer Node.
https://reddit.com/link/1jai33f/video/21ln60itvhoe1/player
I am trying to build a simple spawning feature, where a car is spawned at random time between a min and max value.
I believe this script should world and it does for a while but then the timer node starts getting weird. As you can see it starts to spawn 2 cars at same time. How does this happen?
extends Path2D
u/export var car_scene: PackedScene
u/export var min_spawn_time: float = 2.0
u/export var max_spawn_time: float = 3.0
u/onready var timer: Timer = $Timer
func _ready():
`_spawn_car()`
func _spawn_car():
`print(timer.wait_time)`
`add_child(car_scene.instantiate())`
`timer.start(randf_range(min_spawn_time, max_spawn_time))`
func _on_timer_timeout() -> void:
`_spawn_car()`