master
runs 2020-05-30 21:36:26 +02:00
parent 1c8aa2b19f
commit 53fb2ef878
7 changed files with 13 additions and 8 deletions

View File

@ -30,13 +30,8 @@ end
--a movement test to move the head
function petz.move_head(self, tpos)
local head_position, head_rotation = self.object:get_bone_position("head") -- get the pos and rotation of the head bone. Currently causes a bug!
local pos = self.object:get_pos() --the pos of the mob
tpos.y = tpos.y + 1.625 -- the pos of the eyes of the player
if not(self.head_position) then
local head_position, head_rotation = self.object:get_bone_position("head")
self.head_position = vector.add(head_position, self.head.position_correction) --correction of the pos by cause of the bug, and save it
end
local direction = vector.direction(pos, tpos) -- vector direction from mob to player's eyes
local look_at_dir = vector.normalize(direction) -- important: normalize the vector
-- Functions to calculate the pitch & yaw (in degrees):
@ -46,10 +41,10 @@ function petz.move_head(self, tpos)
local final_yaw = yaw + body_yaw --get the head yaw in reference with the body
head_rotation = {x= pitch, y= final_yaw, z= 0} -- the head movement {pitch, yaw, roll}
self.head_rotation = vector.add(head_rotation, self.head.rotation_origin) --the offset for the rotation, depends on the blender model
self.object:set_bone_position("head", self.head_position, self.head_rotation) --set the head movement
self.object:set_bone_position("head", self.head.position, self.head_rotation) --set the head movement
end
--this sets the mob to move it's head back to pointing forwards
petz.return_head_to_origin = function(self)
self.object:set_bone_position("head", self.head_position, self.head.rotation_origin)
self.object:set_bone_position("head", self.head.position, self.head.rotation_origin)
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -45,8 +45,8 @@ minetest.register_entity("petz:"..pet_name, {
max_hp = 10,
makes_footstep_sound = false,
head = {
position = vector.new(0, 0.2908, -0.2908),
rotation_origin = vector.new(-90, 0, 0), --in degrees, normally values are -90, 0, 90
position_correction = vector.new(0, 0.3, -0.3),
},
attack={range=0.5, damage_groups={fleshy=3}},
animation = {

View File

@ -66,6 +66,11 @@ minetest.register_entity("petz:"..pet_name,{
lung_capacity = 10, -- seconds
max_hp = 8,
head = {
position = vector.new(-0.1939, 0.2908, 0),
rotation_origin = vector.new(-90, 90, 0), --in degrees, normally values are -90, 0, 90
},
attack={range=0.5, damage_groups={fleshy=3}},
animation = {
walk={range={x=1, y=12}, speed=25, loop=true},

View File

@ -45,6 +45,11 @@ minetest.register_entity("petz:"..pet_name, {
max_hp = 8,
makes_footstep_sound = false,
--head = {
--position = vector.new(0, 0.0969, 0.1939),
--rotation_origin = vector.new(-90, -90, 0), --in degrees, normally values are -90, 0, 90
--},
attack={range=0.5, damage_groups={fleshy=3}},
animation = {
walk={range={x=1, y=12}, speed=25, loop=true},