16 lines
469 B
GDScript
16 lines
469 B
GDScript
extends Node2D
|
|
|
|
@export var connected_portal: NodePath
|
|
@onready var portal = get_node(connected_portal)
|
|
var check_for_bodies = true
|
|
|
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
|
if body is Player && check_for_bodies:
|
|
body.global_position = portal.global_position
|
|
body.launch(body.velocity * 1.25)
|
|
portal.check_for_bodies = false
|
|
|
|
|
|
func _on_area_2d_body_exited(body: Node2D) -> void:
|
|
await get_tree().create_timer(0.1).timeout
|
|
check_for_bodies = true
|