From b147b81e01e50c974a5815478601d738b2287169 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 18 Jul 2020 22:50:10 +0200 Subject: [PATCH] Add range check to the new teleporter. --- game/modules/planets/test_planet/dungeons/dung_teleporter.gd | 4 ++++ .../modules/planets/test_planet/dungeons/dung_teleporter.tscn | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/game/modules/planets/test_planet/dungeons/dung_teleporter.gd b/game/modules/planets/test_planet/dungeons/dung_teleporter.gd index d83e8349..d5e3e80f 100644 --- a/game/modules/planets/test_planet/dungeons/dung_teleporter.gd +++ b/game/modules/planets/test_planet/dungeons/dung_teleporter.gd @@ -2,6 +2,7 @@ extends StaticBody export(Color) var default_albedo : Color = Color(0.494118, 0.494118, 0.494118) export(Color) var hover_albedo : Color = Color(0.65098, 0.65098, 0.65098) +export(float) var use_range : float = 3 var teleport_to : Vector3 = Vector3() @@ -37,4 +38,7 @@ func teleport(): if world && world._player: var p : Entity = world._player + if (p.get_body().transform.origin - transform.origin).length() > use_range: + return + p.get_body().transform.origin = teleport_to diff --git a/game/modules/planets/test_planet/dungeons/dung_teleporter.tscn b/game/modules/planets/test_planet/dungeons/dung_teleporter.tscn index 150e1f88..ffb7f897 100644 --- a/game/modules/planets/test_planet/dungeons/dung_teleporter.tscn +++ b/game/modules/planets/test_planet/dungeons/dung_teleporter.tscn @@ -17,7 +17,6 @@ extents = Vector3( 0.5, 0.5, 0.5 ) [node name="DungeonTeleporter" type="StaticBody"] script = ExtResource( 1 ) default_albedo = Color( 0.521569, 0.521569, 0.521569, 1 ) -hover_albedo = Color( 0.65098, 0.65098, 0.65098, 1 ) [node name="MeshInstance" type="MeshInstance" parent="."] mesh = SubResource( 1 )