Adjust "flying" vector checks for mobs
parent
dda7839d8c
commit
5365dec19a
|
@ -205,18 +205,13 @@ end
|
||||||
--this is to swap the built in engine acceleration modifier
|
--this is to swap the built in engine acceleration modifier
|
||||||
local fly_physics_swapper = function(self,inside_fly_node)
|
local fly_physics_swapper = function(self,inside_fly_node)
|
||||||
|
|
||||||
--push non-existing physics switch to new mobs
|
|
||||||
self.fly_physics_switch = self.fly_physics_switch or not inside_fly_node
|
|
||||||
|
|
||||||
--should be flying, gravity is applied, switch to floating
|
--should be flying, gravity is applied, switch to floating
|
||||||
if inside_fly_node and not self.fly_physics_switch then
|
if inside_fly_node and self.object:get_acceleration().y ~= 0 then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector_new(0,0,0))
|
||||||
self.fly_physics_switch = true
|
|
||||||
--not be flying, gravity isn't applied, switch to falling
|
--not be flying, gravity isn't applied, switch to falling
|
||||||
elseif not inside_fly_node and self.fly_physics_switch then
|
elseif not inside_fly_node and self.object:get_acceleration().y == 0 then
|
||||||
self.pitch = 0
|
self.pitch = 0
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
||||||
self.fly_physics_switch = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,10 @@ mobs.set_fly_velocity = function(self, v)
|
||||||
local yaw = (self.yaw or 0)
|
local yaw = (self.yaw or 0)
|
||||||
local pitch = (self.pitch or 0)
|
local pitch = (self.pitch or 0)
|
||||||
|
|
||||||
|
if v == 0 then
|
||||||
|
pitch = 0
|
||||||
|
end
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = {
|
local goal_velocity = {
|
||||||
|
|
Loading…
Reference in New Issue