fix portal script

This commit is contained in:
Nordup 2024-04-01 02:32:31 +04:00
parent b8cc9a768f
commit bcb2108891

View file

@ -1,19 +1,16 @@
extends Node3D extends Node3D
signal portal_entered(url: String)
@export var url: String @export var url: String
func _on_portal_entered(body): func _on_portal_entered(body):
if not body is CharacterBody3D: return if not body is Player: return
if body.get_multiplayer_authority() != multiplayer.get_unique_id(): return
print("Portal_entered: " + url)
await get_tree().create_timer(0.2).timeout await get_tree().create_timer(0.2).timeout
print("portal_entered: " + url)
portal_entered.emit(url) if get_tree().has_method("open_gate"):
get_tree().open_gate(url)
else:
func shut_down(_body) -> void: push_warning("Tree doesn't have method open_gate. Do nothing")
$Portal/MeshInstance3D.visible = false
$Portal/MeshInstance3D2.visible = false
$Portal/OmniLight3D.visible = false
$Portal/CollisionShape3D.set_deferred("disabled", true)