summaryrefslogtreecommitdiff
path: root/Scenes/Components/Teleport.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-04-14 21:49:20 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-04-14 21:49:20 +0200
commitf27937e6e9b6a7146dd09fc711d2d293ecf5abbf (patch)
treee0ddd5e6d356000e4f29af6211a736284a4972ee /Scenes/Components/Teleport.gd
parent96d36cee33d6321834565f0a5d412ef95c5ceffd (diff)
update
Diffstat (limited to 'Scenes/Components/Teleport.gd')
-rw-r--r--Scenes/Components/Teleport.gd26
1 files changed, 26 insertions, 0 deletions
diff --git a/Scenes/Components/Teleport.gd b/Scenes/Components/Teleport.gd
new file mode 100644
index 0000000..03e900f
--- /dev/null
+++ b/Scenes/Components/Teleport.gd
@@ -0,0 +1,26 @@
+extends Node2D
+
+class_name Teleport
+
+@export_node_path("Teleport") var target: NodePath
+
+var targetNode: Teleport
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ self.targetNode = get_node(self.target)
+
+ self.targetNode.get_node("Leave").connect("body_exited", _on_body_exited)
+
+
+func _on_body_entered(body):
+ if body is Player:
+ var player: Player = body
+
+ (func(): self.targetNode.get_node("Enter/CollisionShape2D").disabled = true).call_deferred()
+ player.position = self.targetNode.position
+
+
+func _on_body_exited(body):
+ if body is Player:
+ (func(): targetNode.get_node("Enter/CollisionShape2D").disabled = false).call_deferred()