fixed the camera repositions to work with skinsdb and 3d armor mods

This commit is contained in:
Alexsandro Percy 2023-07-02 16:01:39 -03:00
parent 6b985286b8
commit e09b0815d6
2 changed files with 20 additions and 7 deletions

View file

@ -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");

View file

@ -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)