blob: 03e900f257be1826ea73bdb9bb185fc789b26276 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
|