From cf13adf1e1f2bcaf73fc979d5c963275ae27a5d2 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 19 Sep 2020 14:10:30 +0200 Subject: [PATCH] Add get_closest_point method to Player --- Player.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Player.gd b/Player.gd index 1eb6bc1..556c96d 100644 --- a/Player.gd +++ b/Player.gd @@ -52,6 +52,10 @@ func gravity(): if not is_on_floor(): self.velocity.y -= GRAVITY +func get_closest_point(A: Vector3, B: Vector3): + var diff = B - A + return A - (A.dot(diff) * diff) / (diff.length_squared()) + remote func walk(direction: Vector2): var walkDirectionNormalized = direction.normalized()