Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. [[
  2. vector3(x, y, z)
  3.  
  4. -> {
  5.     clear = <function 8>,
  6.     clone = <function 9>,
  7.     cross = <function 10>,
  8.     dist_to = <function 11>,
  9.     dist_to_2d = <function 12>,
  10.     dot = <function 13>,
  11.     draw_line = <function 14>,
  12.     draw_text = <function 15>,
  13.     is_zero = <function 16>,
  14.     length = <function 17>,
  15.     length_2d = <function 18>,
  16.     length_2d_sqr = <function 19>,
  17.     length_sqr = <function 20>,
  18.     lerp = <function 21>,
  19.     normalize = <function 22>,
  20.     normalize_no_len = <function 23>,
  21.     normalized = <function 24>,
  22.     to_screen = <function 25>,
  23.     trace_bullet = <function 26>,
  24.     trace_line = <function 27>,
  25.     unpack = <function 28>
  26.   }
  27. }
  28. ]]
  29.  
  30. local function get_closest_point(a, b, c)
  31.     local len = a:dist_to(b)
  32.     local dist_min = INF
  33.     local closest = nil
  34.  
  35.     for i=1, len do
  36.         local fraction = i/len
  37.         local pos = a:lerp(b, fraction)
  38.         local dist = pos:dist_to(c)
  39.         if dist_min > dist then
  40.             dist_min = dist
  41.             closest = pos
  42.         end
  43.     end
  44.  
  45.     return closest
  46. end
  47.  
  48. -- in get_shot_yaw(start_pos, end_pos)
  49.  
  50. local closest = get_closest_point(start_pos, end_pos, head_pos)
  51. local closest_dist = closest:dist_to(head_pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement