fix(anim): 3 motion bugs — remote anim dropped, walk->run not resent, wrong class byte
Bug 1: remote chars never animate, just teleport. Root cause: when OnLiveMotionUpdated transitions a remote entity from Ready to a locomotion cycle (cmd=0x0007 RunForward), the _remoteLastMove timestamp is still pegged to the last position update from BEFORE the motion change (often >300ms old). On the very next TickAnimations, stop-detection signal 1 immediately fires (now - last.Time > 300ms), and the sequencer is flipped straight back to Ready. Result: the run cycle flashes for one frame and is gone. Fix: when we enter a locomotion cycle from a non-locomotion one, stamp _remoteLastMove[guid].Time = now and drState.LastServerPosTime = now so the stop-timer starts a fresh 300ms window from the transition. Bug 2 + 3: Our own player's walk/run toggle not broadcast when only Shift toggles mid-move. Root cause: PlayerMovementController's motion-state-change detection compared only (ForwardCommand, SidestepCommand, TurnCommand). When the user walks (W) then adds Shift mid-stride, ForwardCommand stays WalkForward but outForwardSpeed jumps 1.0 -> runRate and localAnimCmd swaps Walk -> Run. 'changed' stayed false, no MoveToState broadcast, server still thought we were walking. Retail observers saw walking. Fix: extend the diff to include outForwardSpeed, input.Run (hold-key), and localAnimCmd. Any of them flipping forces a new MoveToState. Bug 4: Wrong MotionCommand class byte reconstruction. Root cause: OnLiveMotionUpdated's heuristic OR'd the sequencer's current-motion class byte with the wire-received low 16 bits, producing values like 0x41000007 for RunForward (actual retail value is 0x44000007). Cycle key lookup uses only low 24 bits so the animation mostly-worked, but the wrong class byte broke stance-aware code paths and any downstream consumer that keys off the class. Fix: route ForwardCommand through MotionCommandResolver.ReconstructFullCommand (same path already used for Commands[] items) — retail-exact class byte recovery via a reflection-built enum lookup table. Build + 711 tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bd184e1afd
commit
5b84b0785d
2 changed files with 85 additions and 24 deletions
|
|
@ -131,6 +131,9 @@ public sealed class PlayerMovementController
|
|||
private uint? _prevForwardCmd;
|
||||
private uint? _prevSidestepCmd;
|
||||
private uint? _prevTurnCmd;
|
||||
private float? _prevForwardSpeed;
|
||||
private bool _prevRunHold;
|
||||
private uint? _prevLocalAnimCmd;
|
||||
|
||||
// Heartbeat timer.
|
||||
private float _heartbeatAccum;
|
||||
|
|
@ -449,12 +452,40 @@ public sealed class PlayerMovementController
|
|||
}
|
||||
|
||||
// ── 7. Detect motion state change ─────────────────────────────────────
|
||||
bool changed = outForwardCmd != _prevForwardCmd
|
||||
|| outSidestepCmd != _prevSidestepCmd
|
||||
|| outTurnCmd != _prevTurnCmd;
|
||||
_prevForwardCmd = outForwardCmd;
|
||||
_prevSidestepCmd = outSidestepCmd;
|
||||
_prevTurnCmd = outTurnCmd;
|
||||
// Bug fix: ForwardCommand can stay the same (WalkForward) while ONLY
|
||||
// ForwardSpeed or the run-hold bit changes. If the user is already
|
||||
// walking (W held), then presses Shift, the outbound wire still has
|
||||
// ForwardCommand=WalkForward but outForwardSpeed jumps from 1.0 to
|
||||
// runRate. Without also tracking speed + hold-key here, no new
|
||||
// MoveToState is sent — the server keeps thinking the player walks,
|
||||
// and retail observers render walking animation despite the local
|
||||
// player's RunForward cycle.
|
||||
//
|
||||
// Similarly LocalAnimationCommand change (Walk→Run on local cycle)
|
||||
// must force a fresh outbound so ACE's BroadcastMovement re-runs
|
||||
// MovementData(this, moveToState) which only reads ForwardCommand +
|
||||
// ForwardSpeed + HoldKey to pick between WalkForward vs RunForward
|
||||
// for remote observers.
|
||||
bool runHold = input.Run;
|
||||
bool changed = outForwardCmd != _prevForwardCmd
|
||||
|| outSidestepCmd != _prevSidestepCmd
|
||||
|| outTurnCmd != _prevTurnCmd
|
||||
|| !FloatsEqual(outForwardSpeed, _prevForwardSpeed)
|
||||
|| runHold != _prevRunHold
|
||||
|| localAnimCmd != _prevLocalAnimCmd;
|
||||
_prevForwardCmd = outForwardCmd;
|
||||
_prevSidestepCmd = outSidestepCmd;
|
||||
_prevTurnCmd = outTurnCmd;
|
||||
_prevForwardSpeed = outForwardSpeed;
|
||||
_prevRunHold = runHold;
|
||||
_prevLocalAnimCmd = localAnimCmd;
|
||||
|
||||
static bool FloatsEqual(float? a, float? b)
|
||||
{
|
||||
if (a.HasValue != b.HasValue) return false;
|
||||
if (!a.HasValue || !b.HasValue) return true;
|
||||
return System.Math.Abs(a.Value - b.Value) < 1e-4f;
|
||||
}
|
||||
|
||||
// ── 8. Heartbeat timer (only while moving) ────────────────────────────
|
||||
bool isMoving = outForwardCmd is not null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue