1
0
Fork 0

Smooth out mob movement set_velocity more

This commit is contained in:
jordan4ibanez 2021-04-15 11:23:52 -04:00
parent a0ed1a0b20
commit 14207dd96a
1 changed files with 12 additions and 11 deletions

View File

@ -229,13 +229,6 @@ end
-- move mob in facing direction
local set_velocity = function(self, v)
--local c_x, c_y = 0, 0
-- halt mob if it has been ordered to stay
--if self.order == "stand" then
--self.object:set_velocity({x = 0, y = 0, z = 0})
-- return
--end
local yaw = (self.yaw or 0)
@ -247,12 +240,20 @@ local set_velocity = function(self, v)
z = (math_cos(yaw) * v),
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
end
new_velocity_addition.y = 0
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end
@ -1204,7 +1205,7 @@ function mobs:register_arrow(name, def)
rotate = def.rotate,
on_punch = function(self)
local vel = self.object:get_velocity()
self.object:set_velocity({x=vel.x * -1, y=vel.y * -1, z=vel.z * -1})
--self.object:set_velocity({x=vel.x * -1, y=vel.y * -1, z=vel.z * -1})
local pos = self.object:get_pos()
if self.switch == 0