inproved stability in flight

This commit is contained in:
Alexsandro Percy 2022-12-13 19:28:45 -03:00
parent abfdf2b153
commit 8f97786e46
3 changed files with 12 additions and 10 deletions

View File

@ -40,14 +40,14 @@ function delorean.control(self, dtime, hull_direction, longit_speed, longit_drag
--total stop
--wheel break
if longit_speed > 0 then
acc = -5
if (longit_speed + acc) < 0 then
acc = longit_speed * -1
end
end
if not self._is_flying or self._is_flying == 0 then
if longit_speed > 0 then
acc = -5
if (longit_speed + acc) < 0 then
acc = longit_speed * -1
end
end
if longit_speed < 0 then
acc = 5
if (longit_speed + acc) > 0 then
@ -57,6 +57,8 @@ function delorean.control(self, dtime, hull_direction, longit_speed, longit_drag
if math.abs(longit_speed) < 0.2 then
stop = true
end
else
acc = -5
end
end

View File

@ -21,7 +21,7 @@ function delorean.gravity_auto_correction(self, dtime)
--minetest.chat_send_player(self.driver_name, "antes: " .. self._car_gravity)
if self._car_gravity > 0 then factor = -1 end
local time_correction = (dtime/delorean.ideal_step)
local intensity = 1
local intensity = 0.2
local correction = (intensity*factor) * time_correction
--minetest.chat_send_player(self.driver_name, correction)
local before_correction = self._car_gravity
@ -72,6 +72,7 @@ end
function delorean.turn_flight_mode(self)
if self._is_flying == 1 then
--initial lift
self._car_gravity = 5
local curr_pos = self.object:get_pos()
curr_pos.y = curr_pos.y + 1.5
self.object:move_to(curr_pos)

View File

@ -47,12 +47,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local ent = car_obj:get_luaentity()
if ent then
if fields.go_out then
if ent._passenger then --any pax?
local pax_obj = minetest.get_player_by_name(ent._passenger)
automobiles_lib.dettach_pax(ent, pax_obj)
end
ent._is_flying = 0
automobiles_lib.dettach_driver(ent, player)
end
if fields.lights then