From b619e9a4b0a520ef794113b9089aacfbfec22ec7 Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 2 Jul 2023 16:42:20 -0300 Subject: [PATCH] improved camera position and external variables --- lib_planes/entities.lua | 9 ++++++++- lib_planes/utilities.lua | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index 657c64a..4ac4f1e 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -56,6 +56,10 @@ function airutils.on_activate(self, staticdata, dtime_s) self._last_applied_power = -1 --signal to start end end + self._climb_rate = 0 + self._yaw = 0 + self._roll = 0 + self._pitch = 0 if self._register_parts_method then self._register_parts_method(self) @@ -455,7 +459,7 @@ function airutils.logic(self) --GAUGES --minetest.chat_send_all('rate '.. climb_rate) local climb_angle = airutils.get_gauge_angle(climb_rate) - --self.climb_gauge:set_attach(self.object,'',ALBATROS_D5_GAUGE_CLIMBER_POSITION,{x=0,y=0,z=climb_angle}) + self._climb_rate = climb_rate local indicated_speed = longit_speed * 0.9 if indicated_speed < 0 then indicated_speed = 0 end @@ -526,6 +530,9 @@ function airutils.logic(self) --saves last velocity for collision detection (abrupt stop) self._last_vel = self.object:get_velocity() self._last_longit_speed = longit_speed + self._yaw = newyaw + self._roll = newroll + self._pitch = newpitch end local function damage_vehicle(self, toolcaps, ttime, damage) diff --git a/lib_planes/utilities.lua b/lib_planes/utilities.lua index a03d53b..d71c173 100644 --- a/lib_planes/utilities.lua +++ b/lib_planes/utilities.lua @@ -671,18 +671,20 @@ function airutils.camera_reposition(player, pitch, roll) local player_properties = player:get_properties() local new_eye_offset = vector.new() - local eye_y = -4 + local eye_y = -6 if airutils.detect_player_api(player) == 1 then - eye_y = eye_y + 6.5 + --minetest.chat_send_all("1") + eye_y = 0.5 end if airutils.detect_player_api(player) == 2 then - eye_y = -4 + --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, player_properties.eye_height, roll, player_properties.eye_height) + 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