X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=mods%2Fmob%2Fapi%2Fhead_code.lua;h=6fe07e1423e6ae9547f70129b0f241ef879e21f4;hb=81e69c4257ca3210c26d22b8bb36ca406d233744;hp=a06936dc7f01f2f9c826ccce827976dbae5828bc;hpb=c09067c77ece357b018dd03963e0a1e19f9c4686;p=Crafter.git diff --git a/mods/mob/api/head_code.lua b/mods/mob/api/head_code.lua index a06936d..6fe07e1 100644 --- a/mods/mob/api/head_code.lua +++ b/mods/mob/api/head_code.lua @@ -108,6 +108,9 @@ mobs.create_head_functions = function(def,mob_register) ---begin pitch calculation --feed a 2D coordinate flipped into dir to yaw to calculate pitch head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2)) + if self.flip_pitch then + head_rotation.x = head_rotation.x * -1 + end head_rotation.z = head_yaw self.object:set_bone_position(self.head_bone, head_position, head_rotation) return(true) @@ -148,7 +151,7 @@ mobs.create_head_functions = function(def,mob_register) --print(self.head_rotation.y) --if passed a direction to look local pos = self.object:get_pos() - local body_yaw = self.object:get_yaw()-math.pi/2 + local body_yaw = self.object:get_yaw()-math.pi/2+self.rotational_correction local dir = vector.multiply(minetest.yaw_to_dir(body_yaw),self.head_directional_offset) @@ -194,6 +197,9 @@ mobs.create_head_functions = function(def,mob_register) ---begin pitch calculation --feed a 2D coordinate flipped into dir to yaw to calculate pitch head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2)) + if self.flip_pitch then + head_rotation.x = head_rotation.x * -1 + end head_rotation.y = -head_yaw self.object:set_bone_position(self.head_bone, head_position, head_rotation) return(true)