Enable frame blending and head pitch
- Pitch player head up/down based on look dir - Set frame_blend to 0.15, causing 150ms of tweening from one animation to another, so player bone movement is smooth. - Enabling frame_blend breaks some parts of the anims, but oddly, enabling head pitch control actually fixes these... - Head pitch does not follow lookdir 100%, there is some implied use of vertical eye movement balanced in, so the player does not look like they're breaking their neck at extreme angles. - Support anims specifying a head pitch offset, e.g. for the swimming anims which require the head to pitch backward to face forward.
This commit is contained in:
parent
c95dd5dd29
commit
9464f8d534
@ -67,9 +67,9 @@ nodecore.player_anim_data = nodecore.player_anim_data or {
|
||||
walk = {x = 3, y = 27},
|
||||
walk_mine = {x = 28, y = 52},
|
||||
mine = {x = 53, y = 77},
|
||||
swim_mine = {x = 78, y = 108, speed = 0.6},
|
||||
swim_up = {x = 109, y = 133, speed = 0.6},
|
||||
swim_down = {x = 134, y = 158, speed = 0.6},
|
||||
swim_mine = {x = 78, y = 108, speed = 0.6, headpitch = 45},
|
||||
swim_up = {x = 109, y = 133, speed = 0.6, headpitch = 45},
|
||||
swim_down = {x = 134, y = 158, speed = 0.6, headpitch = 45},
|
||||
wave = {x = 159, y = 171, speed = 0.8}
|
||||
}
|
||||
for k, v in pairs(nodecore.player_anim_data) do
|
||||
|
@ -1,8 +1,16 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, pairs
|
||||
= minetest, nodecore, pairs
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math_abs, math_deg
|
||||
= math.abs, math.deg
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local frame_blend = 0.15
|
||||
|
||||
local pitch_mult = 2/3
|
||||
local pitch_limit = 60
|
||||
local pitch_precision = 1
|
||||
|
||||
nodecore.register_playerstep({
|
||||
label = "player model visuals",
|
||||
action = function(player, data)
|
||||
@ -30,6 +38,19 @@ nodecore.register_playerstep({
|
||||
if anim.name then
|
||||
nodecore.player_discover(player, "anim_" .. anim.name)
|
||||
end
|
||||
data.animation = {{x = anim.x, y = anim.y}, anim.speed}
|
||||
data.animation = {{x = anim.x, y = anim.y}, anim.speed, frame_blend}
|
||||
|
||||
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 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 = pitch, y = 0, z = 0}
|
||||
)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user