update for head tracking

This commit is contained in:
Brandon 2020-07-14 20:41:45 -04:00
parent b9ba1300f9
commit 266fd6fc71
1 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,12 @@ local mcl_playerplus_internal = {}
local def = {}
local time = 0
-- converts yaw to degrees
local degrees = function(yaw)
return(yaw*180.0/math.pi)
end
minetest.register_globalstep(function(dtime)
time = time + dtime
@ -14,6 +20,12 @@ minetest.register_globalstep(function(dtime)
-- WARNING: This section is HACKY as hell since it is all just based on heuristics.
for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name()
-- controls head bone
pitch = degrees(player:get_look_vertical()) * -1
yaw = degrees(player:get_look_horizontal())
player:set_bone_position("Head", vector.new(0,6.5,0), vector.new(pitch,0,0))
if mcl_playerplus_internal[name].jump_cooldown > 0 then
mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime
end