rendering: drive Run/Stand animations from actual movement state

CameraController now transitions the player character to Run (anim 4)
on movement start and back to Stand (anim 0) on stop, guarded by a
prevPlayerMoving_ flag so animation time is not reset every frame.
Death animation (anim 1) is never overridden.

Application creature sync similarly switches creature models to Run (4)
when they move between server positions and Stand (0) when they stop,
with per-guid creatureWasMoving_ tracking to avoid per-frame resets.
This commit is contained in:
Kelsi 2026-03-10 10:06:56 -07:00
parent c8d9d6b792
commit 4e137c4061
4 changed files with 37 additions and 2 deletions

View file

@ -1445,6 +1445,21 @@ void CameraController::update(float deltaTime) {
// Honor first-person intent even if anti-clipping pushes camera back slightly.
bool shouldHidePlayer = isFirstPersonView() || (actualDist < MIN_DISTANCE + 0.1f);
characterRenderer->setInstanceVisible(playerInstanceId, !shouldHidePlayer);
// Drive movement animation: Run (4) when moving, Stand (0) when idle.
// Only transition on state changes to avoid resetting animation time every frame.
// Skip if current animation is Death (1) — death pose must persist.
bool nowMoving = isMoving();
if (nowMoving != prevPlayerMoving_) {
prevPlayerMoving_ = nowMoving;
uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f;
bool gotState = characterRenderer->getAnimationState(
playerInstanceId, curAnimId, curT, curDur);
if (!gotState || curAnimId != 1 /*Death*/) {
characterRenderer->playAnimation(playerInstanceId,
nowMoving ? 4u : 0u, /*loop=*/true);
}
}
}
} else {
// Free-fly camera mode (original behavior)