mirror of
https://github.com/moparisthebest/minetest
synced 2025-01-10 21:28:02 -05:00
Fix player:set_animation() in third person view
This commit is contained in:
parent
9370f5657a
commit
cfb26629bf
@ -1101,12 +1101,15 @@ public:
|
|||||||
v2s32 new_anim = v2s32(0,0);
|
v2s32 new_anim = v2s32(0,0);
|
||||||
bool allow_update = false;
|
bool allow_update = false;
|
||||||
|
|
||||||
if(!player->touching_ground &&
|
// increase speed if using fast or flying fast
|
||||||
|
if((g_settings->getBool("fast_move") &&
|
||||||
|
m_gamedef->checkLocalPrivilege("fast")) &&
|
||||||
|
(controls.aux1 ||
|
||||||
|
(!player->touching_ground &&
|
||||||
g_settings->getBool("free_move") &&
|
g_settings->getBool("free_move") &&
|
||||||
m_gamedef->checkLocalPrivilege("fly") &&
|
m_gamedef->checkLocalPrivilege("fly"))))
|
||||||
g_settings->getBool("fast_move") &&
|
new_speed *= 1.5;
|
||||||
m_gamedef->checkLocalPrivilege("fast"))
|
// slowdown speed if sneeking
|
||||||
new_speed *= 1.5;
|
|
||||||
if(controls.sneak && walking)
|
if(controls.sneak && walking)
|
||||||
new_speed /= 2;
|
new_speed /= 2;
|
||||||
|
|
||||||
@ -1121,20 +1124,18 @@ public:
|
|||||||
player->last_animation = DIG_ANIM;
|
player->last_animation = DIG_ANIM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((new_anim.X + new_anim.Y) > 0) {
|
// Apply animations if input detected and not attached
|
||||||
|
// or set idle animation
|
||||||
|
if ((new_anim.X + new_anim.Y) > 0 && !player->isAttached) {
|
||||||
allow_update = true;
|
allow_update = true;
|
||||||
m_animation_range = new_anim;
|
m_animation_range = new_anim;
|
||||||
m_animation_speed = new_speed;
|
m_animation_speed = new_speed;
|
||||||
player->last_animation_speed = m_animation_speed;
|
player->last_animation_speed = m_animation_speed;
|
||||||
} else {
|
} else {
|
||||||
player->last_animation = NO_ANIM;
|
player->last_animation = NO_ANIM;
|
||||||
}
|
|
||||||
// reset animation when no input detected
|
|
||||||
if (!walking && !controls.LMB && !controls.RMB) {
|
|
||||||
player->last_animation = NO_ANIM;
|
|
||||||
if (old_anim != NO_ANIM) {
|
if (old_anim != NO_ANIM) {
|
||||||
m_animation_range = player->local_animations[0];
|
m_animation_range = player->local_animations[0];
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1798,14 +1799,15 @@ public:
|
|||||||
m_animation_blend = readF1000(is);
|
m_animation_blend = readF1000(is);
|
||||||
}
|
}
|
||||||
// update animation only if local animations present
|
// update animation only if local animations present
|
||||||
// and received animation is not unknown
|
// and received animation is unknown (except idle animation)
|
||||||
int frames = 0;
|
bool is_known = false;
|
||||||
for (int i = 0;i<4;i++) {
|
for (int i = 1;i<4;i++) {
|
||||||
frames += (int)player->local_animations[i].Y;
|
if(m_animation_range.Y == player->local_animations[i].Y)
|
||||||
|
is_known = true;
|
||||||
}
|
}
|
||||||
if(frames < 1) {
|
if(!is_known ||
|
||||||
player->last_animation = NO_ANIM;
|
(player->local_animations[1].Y + player->local_animations[2].Y < 1)) {
|
||||||
updateAnimation();
|
updateAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user