Add range check to the new teleporter.

This commit is contained in:
Relintai 2020-07-18 22:50:10 +02:00
parent f96a66300b
commit b147b81e01
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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 )