Change head pitch limigs and offsets

- Move the player head up to show neck again.
- Limit down-looking to not collide with bandolier.
- Slide head forward/back while rotating to keep it
  centered atop the neck and appear connected.
This commit is contained in:
Aaron Suen 2022-01-22 10:47:53 -05:00
parent f9b2e2491a
commit d8c4e5bd94

View File

@ -8,7 +8,8 @@ local math_abs, math_deg
local frame_blend = 0.15
local pitch_mult = 2/3
local pitch_limit = 60
local pitch_max = 60
local pitch_min = -15
local pitch_precision = 1
nodecore.register_playerstep({
@ -42,13 +43,13 @@ nodecore.register_playerstep({
local pitch = -math_deg(player:get_look_vertical()) * pitch_mult
if anim and anim.headpitch then pitch = pitch + anim.headpitch end
if pitch < -pitch_limit then pitch = -pitch_limit end
if pitch > pitch_limit then pitch = pitch_limit end
if pitch < pitch_min then pitch = pitch_min end
if pitch > pitch_max then pitch = pitch_max end
if not (data.headpitch and math_abs(data.headpitch - pitch)
< pitch_precision) then
data.headpitch = pitch
player:set_bone_position("Head",
{x = 0, y = 0, z = 0},
{x = 0, y = 1/2, z = -pitch / 45},
{x = pitch, y = 0, z = 0}
)
end