fligh improvements

This commit is contained in:
Alexsandro Percy 2022-12-13 21:07:59 -03:00
parent e75d1147f5
commit 0810fb2382
2 changed files with 15 additions and 5 deletions

View File

@ -801,7 +801,7 @@ minetest.register_entity("automobiles_delorean:delorean", {
accel.y = -automobiles_lib.gravity
else
local time_correction = (self.dtime/delorean.ideal_step)
local y_accel = self._car_gravity*time_correction
local y_accel = accel.y + self._car_gravity*time_correction
accel.y = y_accel --sets the anti gravity
end
@ -827,7 +827,14 @@ minetest.register_entity("automobiles_delorean:delorean", {
local turn_effect_speed = longit_speed
if turn_effect_speed > 10 then turn_effect_speed = 10 end
newroll = (-self._steering_angle/100)*(turn_effect_speed/10)
if math.abs(self._steering_angle) < 10 then newroll = 0 end
if math.abs(self._steering_angle) < 1 then newroll = 0 end
--pitch
local max_pitch = 6
local h_vel_compensation = (((longit_speed * 2) * 100)/max_pitch)/100
if h_vel_compensation < 0 then h_vel_compensation = 0 end
if h_vel_compensation > max_pitch then h_vel_compensation = max_pitch end
newpitch = newpitch + (velocity.y * math.rad(max_pitch - h_vel_compensation))
end
if newyaw~=yaw or newpitch~=pitch then self.object:set_rotation({x=newpitch,y=newyaw,z=newroll}) 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 = 0.2
local intensity = 0.1
local correction = (intensity*factor) * time_correction
--minetest.chat_send_player(self.driver_name, correction)
local before_correction = self._car_gravity
@ -35,8 +35,11 @@ function delorean.gravity_auto_correction(self, dtime)
--now desacelerate
if self._car_gravity == 0 then
local curr_vel = self.object:get_velocity()
curr_vel.y = 0
self.object:set_velocity(curr_vel)
if curr_vel.y < 0 then
self._car_gravity = 0.5
else
self._car_gravity = -0.5
end
end
--minetest.chat_send_player(self.driver_name, "depois: " .. self._car_gravity)