From 3117bfb77973ae3abcc7db5aebfc5c1941f681cc Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Thu, 1 Apr 2021 14:04:34 +0200 Subject: [PATCH] Fix rotations for changing body pitch --- main.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index a498a51..453b54b 100644 --- a/main.lua +++ b/main.lua @@ -59,8 +59,12 @@ local function clamp(value, range) return value end +local function normalize_angle(angle) + return ((angle + 180) % 360) - 180 +end + local function normalize_rotation(euler_rotation) - return vector.apply(euler_rotation, function(x) return ((x + 180) % 360) - 180 end) + return vector.apply(euler_rotation, normalize_angle) end local function handle_player_animations(dtime, player) @@ -166,6 +170,10 @@ local function handle_player_animations(dtime, player) if interacting then Arm_Right.y = Arm_Right.y + lag_behind end end + -- HACK assumes that Body is root & parent bone of Head, only takes rotation around X-axis into consideration + Head.x = normalize_angle(Head.x + Body.x) + if interacting then Arm_Right.x = normalize_angle(Arm_Right.x + Body.x) end + Head.x = clamp(Head.x, conf.head.pitch) Head.y = clamp(Head.y, conf.head.yaw) if math.abs(Head.y) > conf.head.yaw_restriction then