From 266fd6fc7168ff76a8f4144b4c0e72dc47b620f7 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 14 Jul 2020 20:41:45 -0400 Subject: [PATCH] update for head tracking --- mods/PLAYER/mcl_playerplus/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index d084ee2e5..34f5269c8 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -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