//public Vector3 GetMovementVector (Vector3 point) { public VInt3 GetMovementVector(VInt3 point) { if (vectorPath == null || vectorPath.Count == 0) { //Good Game //return Vector3.zero; return(VInt3.zero); } if (vectorPath.Count == 1) { return(vectorPath[0] - point); } float minDist = float.PositiveInfinity;//Mathf.Infinity; int minSegment = 0; for (int i = 0; i < vectorPath.Count - 1; i++) { //Good Game //Vector3 closest = VectorMath.ClosestPointOnSegment(vectorPath[i], vectorPath[i+1], point); VInt3 closest = IntMath.ClosestPointOnSegment(vectorPath[i], vectorPath[i + 1], point); float dist = (closest - point).sqrMagnitude; if (dist < minDist) { minDist = dist; minSegment = i; } } return(vectorPath[minSegment + 1] - point); }