Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [[
- vector3(x, y, z)
- -> {
- clear = <function 8>,
- clone = <function 9>,
- cross = <function 10>,
- dist_to = <function 11>,
- dist_to_2d = <function 12>,
- dot = <function 13>,
- draw_line = <function 14>,
- draw_text = <function 15>,
- is_zero = <function 16>,
- length = <function 17>,
- length_2d = <function 18>,
- length_2d_sqr = <function 19>,
- length_sqr = <function 20>,
- lerp = <function 21>,
- normalize = <function 22>,
- normalize_no_len = <function 23>,
- normalized = <function 24>,
- to_screen = <function 25>,
- trace_bullet = <function 26>,
- trace_line = <function 27>,
- unpack = <function 28>
- }
- }
- ]]
- local function get_closest_point(a, b, c)
- local len = a:dist_to(b)
- local dist_min = INF
- local closest = nil
- for i=1, len do
- local fraction = i/len
- local pos = a:lerp(b, fraction)
- local dist = pos:dist_to(c)
- if dist_min > dist then
- dist_min = dist
- closest = pos
- end
- end
- return closest
- end
- -- in get_shot_yaw(start_pos, end_pos)
- local closest = get_closest_point(start_pos, end_pos, head_pos)
- local closest_dist = closest:dist_to(head_pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement