From e3ec3a2514d275a56676d935fb6c6a462f06b89b Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 12 Nov 2023 18:26:31 -0300 Subject: [PATCH] fixed hidro buoyance fail --- lib_planes/custom_physics.lua | 7 +++++-- lib_planes/entities.lua | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_planes/custom_physics.lua b/lib_planes/custom_physics.lua index 206aa76..f1f1eea 100755 --- a/lib_planes/custom_physics.lua +++ b/lib_planes/custom_physics.lua @@ -36,10 +36,13 @@ 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 = 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} + 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 if last_accel then accell = vector.add(accell,last_accel) diff --git a/lib_planes/entities.lua b/lib_planes/entities.lua index c959901..4a67728 100644 --- a/lib_planes/entities.lua +++ b/lib_planes/entities.lua @@ -331,7 +331,7 @@ function airutils.logic(self) if (math.abs(velocity.x) < 0.1 and math.abs(velocity.z) < 0.1) and is_flying == false and is_attached == false and self._engine_running == false then if self._ground_friction then - if self._ground_friction > 0.97 then self.object:set_velocity({x=0,y=airutils.gravity*self.dtime,z=0}) end + if self._ground_friction > 0.97 and self.buoyancy >= 1 then self.object:set_velocity({x=0,y=airutils.gravity*self.dtime,z=0}) end end return end