improved camera position and external variables

This commit is contained in:
Alexsandro Percy 2023-07-02 16:42:20 -03:00
parent e09b0815d6
commit b619e9a4b0
2 changed files with 14 additions and 5 deletions

View File

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

View File

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