Add get_closest_point method to Player

This commit is contained in:
Jan 2020-09-19 14:10:30 +02:00
parent 1456dacc30
commit cf13adf1e1

View file

@ -52,6 +52,10 @@ func gravity():
if not is_on_floor(): if not is_on_floor():
self.velocity.y -= GRAVITY 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): remote func walk(direction: Vector2):
var walkDirectionNormalized = direction.normalized() var walkDirectionNormalized = direction.normalized()