Error: "start: Timer was not added to the SceneTree. Either add it or set autostart to true."

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

I have an enemy with a timer attached to it. When the player attacks the enemy, it dies and gets destroyed, and that is when this error gets fired. Everything works fine and does as expected but this error is just a bit annoying. Here’s the code:

onready var idleTimer = $IdleTimer

func _on_DetectionArea_body_entered(body):
    idleTimer.stop()
    if isActive == false:
	    animSprite.play("Wakeup")
	    yield(animSprite,"animation_finished")
	    animSprite.play("Active")
	    isActive = true


func _on_DetectionArea_body_exited(body):
    idleTimer.start()


func _on_IdleTimer_timeout():
    if  $DetectionArea.get_overlapping_areas():
	    idleTimer.stop()
    else:
	    isActive = false
	    animSprite.play("Death")
	    yield(animSprite, "animation_finished")
	    animSprite.play("Idle")


func _on_Hurtbox_area_entered(area):
    animSprite.play("Death")
    $Hurtbox.set_deferred("monitoring", false)
    $Hitbox.set_deferred("monitorable", false)
    yield(animSprite, "animation_finished")
    queue_free()
:bust_in_silhouette: Reply From: jeudyx

This is a super weird one. Instead of calling .start(), set autostart = true

Just had the same issue.

I did this and it still dosen’t work, the Timer dosen’t timeout at all.

javrocks | 2023-06-28 00:30