Last active
October 23, 2021 04:04
-
-
Save iamjoeysox/87f233757e242c01313726e511b96c0b to your computer and use it in GitHub Desktop.
Allow players to travel between scenes through a 2D portal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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