mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
added method to update head position for the pilot
This commit is contained in:
parent
3f84d1d11c
commit
eb052e3df5
2 changed files with 27 additions and 1 deletions
|
@ -229,7 +229,7 @@ function airutils.logic(self)
|
|||
--is an stall, force a recover
|
||||
if longit_speed < (self._min_speed+0.5) and climb_rate < -1.5 and is_flying then
|
||||
if player and self.driver_name then
|
||||
minetest.chat_send_player(self.driver_name,core.colorize('#ff0000', " >>> STALL"))
|
||||
--minetest.chat_send_player(self.driver_name,core.colorize('#ff0000', " >>> STALL"))
|
||||
end
|
||||
self._elevator_angle = 0
|
||||
self._angle_of_attack = -1
|
||||
|
@ -419,6 +419,7 @@ function airutils.logic(self)
|
|||
local indicated_speed = longit_speed * 0.9
|
||||
if indicated_speed < 0 then indicated_speed = 0 end
|
||||
self._indicated_speed = indicated_speed
|
||||
local speed_angle = supercub.get_gauge_angle(indicated_speed, -45)
|
||||
|
||||
--adjust power indicator
|
||||
local power_indicator_angle = airutils.get_gauge_angle(self._power_lever/10)
|
||||
|
@ -440,6 +441,11 @@ function airutils.logic(self)
|
|||
newyaw = yaw + yaw_turn
|
||||
end
|
||||
|
||||
if player then
|
||||
local new_eye_offset = airutils.camera_reposition(player, newpitch, math.rad(self._rudder_angle))
|
||||
player:set_eye_offset(new_eye_offset, {x = 0, y = 1, z = -30})
|
||||
end
|
||||
|
||||
--apply rotations
|
||||
self.object:set_rotation({x=newpitch,y=newyaw,z=newroll})
|
||||
--end
|
||||
|
|
|
@ -519,3 +519,23 @@ function airutils.add_destruction_effects(pos, radius)
|
|||
texture = "airutils_smoke.png",
|
||||
})
|
||||
end
|
||||
|
||||
function airutils.get_xz_from_hipotenuse(orig_x, orig_z, yaw, distance)
|
||||
--cara, o minetest é bizarro, ele considera o eixo no sentido ANTI-HORÁRIO... Então pra equação funcionar, subtrair o angulo de 360 antes
|
||||
yaw = math.rad(360) - yaw
|
||||
local z = (math.cos(yaw)*distance) + orig_z
|
||||
local x = (math.sin(yaw)*distance) + orig_x
|
||||
return x, z
|
||||
end
|
||||
|
||||
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)
|
||||
new_eye_offset.z = z
|
||||
new_eye_offset.y = y
|
||||
local x, _ = airutils.get_xz_from_hipotenuse(0, player_properties.eye_height, roll, player_properties.eye_height)
|
||||
new_eye_offset.x = x*7
|
||||
return new_eye_offset
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue