mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 12:31:05 +01:00
move relative animation speed to separate function
This commit is contained in:
parent
18c415f6a0
commit
c9c2b874be
2 changed files with 22 additions and 20 deletions
|
@ -454,26 +454,7 @@ function mob_class:on_step(dtime)
|
||||||
self:follow_flop()
|
self:follow_flop()
|
||||||
|
|
||||||
--set animation speed relitive to velocity
|
--set animation speed relitive to velocity
|
||||||
local v = self.object:get_velocity()
|
self:set_animation_speed()
|
||||||
if v then
|
|
||||||
if self.frame_speed_multiplier then
|
|
||||||
local v2 = math.abs(v.x)+math.abs(v.z)*.833
|
|
||||||
if not self.animation.walk_speed then
|
|
||||||
self.animation.walk_speed = 25
|
|
||||||
end
|
|
||||||
if math.abs(v.x)+math.abs(v.z) > 0.5 then
|
|
||||||
self.object:set_animation_frame_speed((v2/math.max(1,self.run_velocity))*self.animation.walk_speed*self.frame_speed_multiplier)
|
|
||||||
else
|
|
||||||
self.object:set_animation_frame_speed(25)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--set_speed
|
|
||||||
if self.acc then
|
|
||||||
self.object:add_velocity(self.acc)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- smooth rotation by ThomasMonroe314
|
-- smooth rotation by ThomasMonroe314
|
||||||
if self._turn_to then
|
if self._turn_to then
|
||||||
|
|
|
@ -350,6 +350,27 @@ function mob_class:check_head_swivel()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mob_class:set_animation_speed()
|
||||||
|
local v = self.object:get_velocity()
|
||||||
|
if v then
|
||||||
|
if self.frame_speed_multiplier then
|
||||||
|
local v2 = math.abs(v.x)+math.abs(v.z)*.833
|
||||||
|
if not self.animation.walk_speed then
|
||||||
|
self.animation.walk_speed = 25
|
||||||
|
end
|
||||||
|
if math.abs(v.x)+math.abs(v.z) > 0.5 then
|
||||||
|
self.object:set_animation_frame_speed((v2/math.max(1,self.run_velocity))*self.animation.walk_speed*self.frame_speed_multiplier)
|
||||||
|
else
|
||||||
|
self.object:set_animation_frame_speed(25)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--set_speed
|
||||||
|
if self.acc then
|
||||||
|
self.object:add_velocity(self.acc)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local pn = player:get_player_name()
|
local pn = player:get_player_name()
|
||||||
if not active_particlespawners[pn] then return end
|
if not active_particlespawners[pn] then return end
|
||||||
|
|
Loading…
Reference in a new issue