summaryrefslogtreecommitdiff
path: root/godot/scenes/environment/Ladder.gd
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2022-09-07 14:07:30 -0400
committerAnson Bridges <bridges.anson@gmail.com>2022-09-07 14:07:30 -0400
commitc232b92e2dde1277324d1f89d0e75ae641e4ac3b (patch)
treee11a5dd52f259c1cc7345baa40b372b304417f00 /godot/scenes/environment/Ladder.gd
parenta0967ebe815cd229b69fb9578f2288b95b2ddb28 (diff)
reorganized, ladders, vehicle control
Diffstat (limited to 'godot/scenes/environment/Ladder.gd')
-rw-r--r--godot/scenes/environment/Ladder.gd21
1 files changed, 21 insertions, 0 deletions
diff --git a/godot/scenes/environment/Ladder.gd b/godot/scenes/environment/Ladder.gd
new file mode 100644
index 0000000..af31c3f
--- /dev/null
+++ b/godot/scenes/environment/Ladder.gd
@@ -0,0 +1,21 @@
+extends Spatial
+
+onready var top = $Top
+onready var bottom = $Bottom
+
+func _ready():
+ if !OS.is_debug_build():
+ $DebugVisMesh.visible = false
+
+#point at which a player should enter the ladder given their current location
+func get_nearest_point_to_route(point_global: Vector3) -> Vector3:
+ var t : Vector3 = top.global_transform.origin
+ var b : Vector3 = bottom.global_transform.origin
+ return b + clamp(get_climb_scalar(point_global), 0.0, 1.0)*(t-b)
+
+#ladder climb "progress"
+func get_climb_scalar(point_global: Vector3) -> float:
+ var t : Vector3 = top.global_transform.origin
+ var b : Vector3 = bottom.global_transform.origin
+ #(T−B)⋅(P-B) / (T−B)⋅(T−B)
+ return (t-b).dot(point_global-b) / (t-b).dot(t-b)