Switch player to area teleport

I previously added in a "body" detected teleportation, but it was
flickering weirdly.. It is solvable with checking the dot product for
bodies passing the portal threshold tho. Someday
This commit is contained in:
Vojtěch Struhár 2025-02-11 12:13:43 +01:00
parent 16d7841e6e
commit f24fc0b3c1
2 changed files with 18 additions and 4 deletions

View File

@ -26,5 +26,5 @@ func _on_area_entered(area: Area3D) -> void:
root.global_transform = _parent_portal.real_to_exit_transform(root.global_transform)
func _on_body_entered(body: Node3D) -> void:
if body.has_meta("teleportable"):
if body.get_meta("teleportable", false) == true:
body.global_transform = _parent_portal.real_to_exit_transform(body.global_transform)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://dpatwnepecl8r"]
[gd_scene load_steps=13 format=3 uid="uid://dpatwnepecl8r"]
[ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="1_ig7tw"]
[ext_resource type="Script" uid="uid://bp1bo57yqtv65" path="res://player.gd" id="2_0xm2m"]
@ -19,9 +19,12 @@ sky = SubResource("Sky_0xm2m")
glow_enabled = true
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_0xm2m"]
radius = 0.05
radius = 0.4
height = 1.75
[sub_resource type="SphereShape3D" id="SphereShape3D_lquwl"]
radius = 0.005
[sub_resource type="Environment" id="Environment_7mycd"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1bvp3"]
@ -46,18 +49,22 @@ omni_range = 4.0
[node name="OmniLight3D2_green" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16, 2, -3)
light_color = Color(0.565916, 0.798943, 0.502176, 1)
omni_range = 4.0
[node name="OmniLight3D3_orange" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 32, 2, -3)
light_color = Color(0.933244, 0.547562, 0.264524, 1)
omni_range = 4.0
[node name="OmniLight3D4_purple" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 9)
light_color = Color(0.782893, 0.635622, 0.949367, 1)
omni_range = 4.0
[node name="OmniLight3D5_red" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16, 2, 9)
light_color = Color(1, 0.239216, 0.345098, 1)
omni_range = 4.0
[node name="OmniLight3D6" type="OmniLight3D" parent="."]
@ -67,7 +74,7 @@ omni_range = 4.0
[node name="Player" type="CharacterBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.28597, -3)
script = ExtResource("2_0xm2m")
metadata/teleportable = true
metadata/teleportable = false
[node name="Camera3D" type="Camera3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.32153, 0)
@ -76,6 +83,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.32153, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.875, 0)
shape = SubResource("CapsuleShape3D_0xm2m")
[node name="TeleportTrigger" type="Area3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.875, 0)
metadata/teleportable_root = NodePath("..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player/TeleportTrigger"]
shape = SubResource("SphereShape3D_lquwl")
[node name="P_white_short" type="MeshInstance3D" parent="." node_paths=PackedStringArray("exit_portal")]
transform = Transform3D(-4.80825e-08, 0, 1.1, 0, 1.1, 0, -1.1, 0, -4.80825e-08, -5.5, 2, -3)
mesh = ExtResource("3_1bvp3")