Skip to content

Instantly share code, notes, and snippets.

@iamjoeysox
Last active October 23, 2021 04:04
Show Gist options
  • Save iamjoeysox/87f233757e242c01313726e511b96c0b to your computer and use it in GitHub Desktop.
Save iamjoeysox/87f233757e242c01313726e511b96c0b to your computer and use it in GitHub Desktop.
Allow players to travel between scenes through a 2D portal
tool
extends Area2D
onready var anim_player: AnimationPlayer = $AnimationPlayer
export var next_scene: PackedScene
func _on_body_entered(body: PhysicsBody2D):
teleport()
func _get_configuration_warning() -> String:
return "The property Next Level can't be empty" if not next_scene else ""
func teleport() -> void:
get_tree().paused = true
anim_player.play("fade_out")
yield(anim_player, "animation_finished")
get_tree().paused = false
get_tree().change_scene_to(next_scene)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment