immersive-home/addons/godot-xr-tools/objects/teleport_area.gd

30 lines
629 B
GDScript3
Raw Normal View History

2023-10-16 20:10:20 +03:00
@tool
class_name XRToolsTeleportArea
extends Area3D
## Target node
@export var target : Node3D
# Add support for is_xr_class on XRTools classes
func is_xr_class(name : String) -> bool:
return name == "XRToolsTeleportArea"
# Called when the node enters the scene tree for the first time.
func _ready():
# Handle body entered
body_entered.connect(_on_body_entered)
# Handle body entering area
func _on_body_entered(body : Node3D) -> void:
# Test if the body is the player
var player_body := body as XRToolsPlayerBody
if not player_body:
return
# Teleport the player
player_body.teleport(target.global_transform)