From e09b0815d6dcb91a5f6beac75442f4d908d88fc4 Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 2 Jul 2023 16:01:39 -0300 Subject: [PATCH] fixed the camera repositions to work with skinsdb and 3d armor mods --- init.lua | 5 +++++ lib_planes/utilities.lua | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 40d1a07..a692bbb 100644 --- a/init.lua +++ b/init.lua @@ -123,11 +123,16 @@ function airutils.detect_player_api(player) --if player_proterties.mesh == mesh then local models = player_api.registered_models local character = models[player_proterties.mesh] + --minetest.chat_send_all(dump(character)); if character then if character.animations.sit.eye_height then + --minetest.chat_send_all(dump(character.animations.sit.eye_height)); if character.animations.sit.eye_height == 0.8 then --minetest.chat_send_all("new model"); return 1 + else + --minetest.chat_send_all("new height"); + return 2 --strange bug with armor ands skins returning 1.47 end else --minetest.chat_send_all("old model"); diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index 27e3f56..a03d53b 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -51,7 +51,10 @@ function airutils.attach(self, player, instructor_mode) if airutils.detect_player_api(player) == 1 then eye_y = eye_y + 6.5 end - + if airutils.detect_player_api(player) == 2 then + eye_y = -4 + end + player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 1, z = -30}) player_api.player_attached[name] = true player_api.set_animation(player, "sit") @@ -156,11 +159,7 @@ function airutils.attach_pax(self, player, is_copilot) --minetest.chat_send_all(self.driver_name) self._passengers[i] = name player:set_attach(self._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) - if i > 2 then - player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30}) - else - player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30}) - end + player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30}) player_api.player_attached[name] = true player_api.set_animation(player, "sit") -- make the driver sit @@ -671,7 +670,16 @@ function airutils.camera_reposition(player, pitch, roll) local player_properties = player:get_properties() local new_eye_offset = vector.new() - local z, y = airutils.get_xz_from_hipotenuse(0, player_properties.eye_height, pitch, player_properties.eye_height) + + local eye_y = -4 + if airutils.detect_player_api(player) == 1 then + eye_y = eye_y + 6.5 + end + if airutils.detect_player_api(player) == 2 then + eye_y = -4 + 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, player_properties.eye_height, roll, player_properties.eye_height)