X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=mods%2Fmob%2Fapi%2Fanimation.lua;h=8f8660a49ee53597dd1fe882b43cfa513a0a7534;hb=f39b7a6138697251614a5472b7d68a3ed1defd30;hp=2c52b1cb726d777b47cc341ad766c690128d6145;hpb=d086df2302682e64389ac7a856af67853d700e44;p=Crafter.git diff --git a/mods/mob/api/animation.lua b/mods/mob/api/animation.lua index 2c52b1c..8f8660a 100644 --- a/mods/mob/api/animation.lua +++ b/mods/mob/api/animation.lua @@ -1,18 +1,21 @@ +local math,vector = math,vector -- mobs.create_animation_functions = function(def,mob_register) - mob_register.set_animation = function(self) - if self.speed == 0 or vector.equals(self.direction,vector.new(0,0,0)) then - self.current_animation = 0 - self.object:set_animation(def.standing_frame, 1, 0, true) - else - if self.current_animation ~= 1 then - self.object:set_animation(def.moving_frame, 1, 0, true) - self.current_animation = 1 + if def.movement_type ~= "jump" then + mob_register.set_animation = function(self) + if self.speed == 0 or vector.equals(self.direction,vector.new(0,0,0)) then + self.current_animation = 0 + self.object:set_animation(def.standing_frame, 1, 0, true) + else + if self.current_animation ~= 1 then + self.object:set_animation(def.moving_frame, 1, 0, true) + self.current_animation = 1 + end + + local speed = self.object:get_velocity() + speed.y = 0 + self.object:set_animation_frame_speed(vector.distance(vector.new(0,0,0),speed)*def.animation_multiplier) end - - local speed = self.object:get_velocity() - speed.y = 0 - self.object:set_animation_frame_speed(vector.distance(vector.new(0,0,0),speed)*def.animation_multiplier) end end @@ -36,12 +39,12 @@ mobs.create_animation_functions = function(def,mob_register) end --print(self.death_animation_timer) - local currentvel = self.object:getvelocity() + local currentvel = self.object:get_velocity() local goal = vector.new(0,0,0) local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z) acceleration = vector.multiply(acceleration, 0.05) self.object:add_velocity(acceleration) - self.object:set_animation({x=0,y=0}, 15, 0, true) + self.object:set_animation(def.standing_frame, 15, 0, true) end end return(mob_register)