diff --git a/init.lua b/init.lua index 8d66975..7f35367 100644 --- a/init.lua +++ b/init.lua @@ -331,9 +331,9 @@ function airutils.getLiftAccel(self, velocity, accel, longit_speed, roll, curr_p return retval end -function airutils.get_plane_pitch(velocity, longit_speed, min_speed, angle_of_attack) +function airutils.get_plane_pitch(y_velocity, longit_speed, min_speed, angle_of_attack) local v_speed_factor = 0 - if longit_speed > 0 then v_speed_factor = (velocity.y * math.rad(2)) end --the pitch for climbing or descenting + if longit_speed > 0 then v_speed_factor = (y_velocity * math.rad(2)) end --the pitch for climbing or descenting local min_rotation_speed = min_speed/2 local pitch_by_longit_speed = 0 if longit_speed > min_rotation_speed then --just start the rotation after the rotation speed diff --git a/lib_planes/custom_physics.lua b/lib_planes/custom_physics.lua index a394f54..eec787d 100755 --- a/lib_planes/custom_physics.lua +++ b/lib_planes/custom_physics.lua @@ -32,7 +32,8 @@ function airutils.physics(self) local height = self.height local submergence = math.min(surface-spos.y,height)/height -- local balance = self.buoyancy*self.height - local buoyacc = airutils.gravity*(self.buoyancy-submergence) + --local buoyacc = airutils.gravity*(self.buoyancy-submergence) + local buoyacc = airutils.gravity*(self.buoyancy-submergence) --local buoyacc = self._baloon_buoyancy*(self.buoyancy-submergence) accell = {x=-vel.x*self.water_drag,y=buoyacc-(vel.y*math.abs(vel.y)*0.4),z=-vel.z*self.water_drag} if self.buoyancy >= 1 then self._engine_running = false end @@ -41,7 +42,7 @@ function airutils.physics(self) self.object:move_to(self.object:get_pos()) return else - airutils.set_acceleration(self.object,{x=0,y=airutils.gravity,z=0}) + --airutils.set_acceleration(self.object,{x=0,y=airutils.gravity,z=0}) self.isinliquid = false --new_velocity = vector.add(new_velocity, {x=0,y=airutils.gravity * self.dtime,z=0}) end diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index c253156..0f08c04 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -322,14 +322,16 @@ function airutils.logic(self) end --adjust climb indicator - local climb_rate = velocity.y + local y_velocity = 0 + if self._engine_running or is_flying then y_velocity = velocity.y end + local climb_rate = y_velocity if climb_rate > 5 then climb_rate = 5 end if climb_rate < -5 then climb_rate = -5 end -- pitch - local newpitch = airutils.get_plane_pitch(velocity, longit_speed, self._min_speed, self._angle_of_attack) + local newpitch = airutils.get_plane_pitch(y_velocity, longit_speed, self._min_speed, self._angle_of_attack) --for airplanes with cannard or pendulum wing local actuator_angle = self._elevator_angle @@ -499,11 +501,16 @@ function airutils.logic(self) self.object:move_to(curr_pos) --airutils.set_acceleration(self.object, new_accel) local limit = (self._max_speed/self.dtime) - local vel_to_add = vector.multiply(new_accel,self.dtime) if new_accel.y > limit then new_accel.y = limit end --it isn't a rocket :/ - vel_to_add.y = 0 + + if not self.isinliquid then --why? because whe work water movements in the phisics code + new_accel.y = new_accel.y + airutils.gravity --gravity here + end + + local vel_to_add = vector.multiply(new_accel,self.dtime) + --vel_to_add.y = 0 self.object:add_velocity(vel_to_add) - self.object:set_acceleration({x=0,y=new_accel.y, z=0}) + --self.object:set_acceleration({x=0,y=new_accel.y, z=0}) else if stop == true then self._last_accell = self.object:get_acceleration()