portal 2 still alive

This commit is contained in:
pennyrigate 2025-03-06 21:12:36 -05:00
parent 2f9f4877d9
commit 07eb3ed129
17 changed files with 311 additions and 7 deletions

16
objects/portal/portal.gd Normal file
View file

@ -0,0 +1,16 @@
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