Instanced scene doesn't come up after signal "timeout"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By congbinh75

I’m following Your First Game to make my own project and try the same way to spawn enemy.

The enemy scene comes up on the screen once after the first “timeout” signal but after that the scene doesn’t appear anymore.

Here is the stage’s scripts:

extends Node2D

var f_as1 = preload("res://elements/formations/f_alpha_straight_toptobot_ch1.tscn")
var aship = preload("res://elements/elements/e_enemy_alpha.tscn")
export (PackedScene) var enemy

func _ready():
	$Timer.start()
	pass

func _on_Timer_timeout():
	enemy = f_as1.instance()
	add_child(enemy)
	$Timer.start()
	pass

Thanks in advance!

I’m sure you already checked this, but i have to ask… you have one shot property of timer unchecked, don’t you?

p7f | 2019-01-16 11:28

Oh, never mind… you start the timer again inside.

p7f | 2019-01-16 11:36

I pasted your code in my pc and works. Could you share the project? may be mistake is elsewhere

p7f | 2019-01-16 11:42

I had a bug once that the signal would not be sent to the same script (to self), I had to create a new script just no handle the timeout. Maybe this is what is happening.

fpicoral | 2019-01-16 11:46

and could you share the project?

p7f | 2019-01-16 11:53