mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-27 03:37:31 +01:00
Fix arrows getting stuck in impossible ways
This commit is contained in:
parent
c7949bf703
commit
0ec411b868
@ -239,36 +239,11 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
self._stuckin = nil
|
self._stuckin = nil
|
||||||
if self._deflection_cooloff <= 0 then
|
if self._deflection_cooloff <= 0 then
|
||||||
-- Lose 1/3 of velocity on deflection
|
-- Lose 1/3 of velocity on deflection
|
||||||
self.object:set_velocity(vector.multiply(vel, 0.6667))
|
local newvel = vector.multiply(vel, 0.6667)
|
||||||
|
|
||||||
-- Just some dirty hack to make sure the arrow has a minimum direction to
|
self.object:set_velocity(newvel)
|
||||||
-- avoid triggering the stuck detection again.
|
|
||||||
vel = self.object:get_velocity()
|
|
||||||
if math.abs(vel.x) < 0.0001 then
|
|
||||||
if pos.x < self._lastpos.x then
|
|
||||||
vel.x = 0.01
|
|
||||||
else
|
|
||||||
vel.x = -0.01
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if math.abs(vel.z) < 0.0001 then
|
|
||||||
if pos.z < self._lastpos.z then
|
|
||||||
vel.z = 0.01
|
|
||||||
else
|
|
||||||
vel.z = -0.01
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if math.abs(vel.y) < 0.00001 then
|
|
||||||
if pos.y < self._lastpos.y then
|
|
||||||
vel.y = 0.001
|
|
||||||
else
|
|
||||||
vel.y = -0.001
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
self.object:set_yaw(minetest.dir_to_yaw(vel)+YAW_OFFSET)
|
|
||||||
-- Reset deflection cooloff timer to prevent many deflections happening in quick succession
|
-- Reset deflection cooloff timer to prevent many deflections happening in quick succession
|
||||||
self._deflection_cooloff = 0.2
|
self._deflection_cooloff = 1.0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user