diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index b4b4c5c..283fc29 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -751,30 +751,29 @@ function airutils.get_xz_from_hipotenuse(orig_x, orig_z, yaw, distance) end function airutils.camera_reposition(player, pitch, roll) - local new_eye_offset = vector.new() - if airutils.is_minetest then - if roll < -0.4 then roll = -0.4 end - if roll > 0.4 then roll = 0.4 end + local new_eye_offset = player:get_eye_offset() - local player_properties = player:get_properties() + if roll < -0.4 then roll = -0.4 end + if roll > 0.4 then roll = 0.4 end - local eye_y = -5 - if airutils.detect_player_api(player) == 1 then - --minetest.chat_send_all("1") - eye_y = 0.5 - end - if airutils.detect_player_api(player) == 2 then - --minetest.chat_send_all("2") - eye_y = -5 - end - - local z, y = airutils.get_xz_from_hipotenuse(0, eye_y, pitch, player_properties.eye_height) - new_eye_offset.z = z*7 - new_eye_offset.y = y*1.5 - local x, _ = airutils.get_xz_from_hipotenuse(0, eye_y, roll, player_properties.eye_height) - new_eye_offset.x = -x*15 - return new_eye_offset + local player_properties = player:get_properties() + + local eye_y = -5 + if airutils.detect_player_api(player) == 1 then + --minetest.chat_send_all("1") + eye_y = 0.5 end + if airutils.detect_player_api(player) == 2 then + --minetest.chat_send_all("2") + eye_y = -5 + end + + local z, y = airutils.get_xz_from_hipotenuse(0, eye_y, pitch, player_properties.eye_height) + new_eye_offset.z = z*7 + new_eye_offset.y = y*1.5 + local x, _ = airutils.get_xz_from_hipotenuse(0, eye_y, roll, player_properties.eye_height) + new_eye_offset.x = -x*15 + return new_eye_offset end