33 lines
731 B
GDScript
33 lines
731 B
GDScript
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,400,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)
|
|
scene.global_position = global_position + SCENE_SPAWN_OFFSET
|
|
|
|
entered = true
|
|
if active and entered:
|
|
var spawned_stuff = scene_holder.get_children()
|
|
for i in spawned_stuff:
|
|
i.queue_free()
|
|
|
|
|
|
func _on_start_activation_timeout() -> void:
|
|
active = true
|