mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
fix undesired movement
This commit is contained in:
parent
a81abe7ae5
commit
157ed5de4f
1 changed files with 10 additions and 4 deletions
|
@ -24,7 +24,10 @@ function airutils.physics(self)
|
||||||
if surface then -- standing in liquid
|
if surface then -- standing in liquid
|
||||||
self.isinliquid = true
|
self.isinliquid = true
|
||||||
end
|
end
|
||||||
local last_accel = self._last_accel
|
local last_accel = nil
|
||||||
|
if self._last_accel then
|
||||||
|
last_accel = airutils.properties_copy(self._last_accel)
|
||||||
|
end
|
||||||
|
|
||||||
if self.isinliquid then
|
if self.isinliquid then
|
||||||
local accell = {x=0, y=0, z=0}
|
local accell = {x=0, y=0, z=0}
|
||||||
|
@ -48,7 +51,7 @@ function airutils.physics(self)
|
||||||
--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
|
self.isinliquid = false
|
||||||
|
|
||||||
if self._last_accel then
|
if last_accel then
|
||||||
last_accel.y = last_accel.y + airutils.gravity --gravity here
|
last_accel.y = last_accel.y + airutils.gravity --gravity here
|
||||||
|
|
||||||
new_velocity = vector.multiply(last_accel,self.dtime)
|
new_velocity = vector.multiply(last_accel,self.dtime)
|
||||||
|
@ -95,9 +98,12 @@ function airutils.physics(self)
|
||||||
|
|
||||||
--self.object:set_velocity(new_velocity)
|
--self.object:set_velocity(new_velocity)
|
||||||
--new_velocity = vector.subtract(new_velocity,vel)
|
--new_velocity = vector.subtract(new_velocity,vel)
|
||||||
end
|
|
||||||
|
|
||||||
self.object:add_velocity(new_velocity)
|
--fix to stop planes moving by itself when at airports
|
||||||
|
self.object:set_velocity(vector.add(new_velocity,vel))
|
||||||
|
else
|
||||||
|
self.object:add_velocity(new_velocity)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue