extends Node2D var totalCrates = 2 #This will be updated in the future, see SceneManager var cratesDestroyed = 0 var timeLimit = 10 var timer:= Timer.new() # Called when the node enters the scene tree for the first time. func _ready(): add_child(timer) timer.wait_time = 1 timer.one_shot = false timer.connect("timeout", secondCounter) timer.start() func secondCounter(): timeLimit -= 1 if timeLimit <=0: print("You lose baby!") get_tree().reload_current_scene() func _on_area_2d_areatrigger(effect, body): # check to ensure the collision is with the crates (RigidBodies) # A CharacterBody2D should not trigger a reaction to the collision if body is RigidBody2D: # crate entered trigger # handle effects match effect: "destroy": cratesDestroyed +=1 body.queue_free() # destroy the crate - again will move to SceneManager if cratesDestroyed>=totalCrates: print("You win baby!") get_tree().reload_current_scene()