extends Area3D class_name Portal var level_info = {} var active = true var entered = false var index : int @onready var timer: Timer = $Timer @onready var scene_holder: Node3D = $Scene_Holder const SCENE_SPAWN_OFFSET = Vector3(0,500,0) func _on_body_entered(body: Node3D) -> void: if body is Player: if active and !entered: active = false timer.start(1) var scene = load(level_info["level_path"]).instantiate() scene_holder.add_child(scene) var spawn_tube_offset_pos = Vector3.ZERO if scene.tube_top != null: spawn_tube_offset_pos = scene.tube_top.position scene.global_position = global_position + SCENE_SPAWN_OFFSET + spawn_tube_offset_pos var level_control = get_tree().current_scene level_control.spawn_crown() entered = true if active and entered: HelperFuncs.clear_spawned_objects() var spawned_stuff = scene_holder.get_children() for i in spawned_stuff: i.queue_free() func _on_start_activation_timeout() -> void: active = true