fix movement

This commit is contained in:
Andras Schmelczer 2026-08-22 15:29:30 +01:00
commit aa02d0ab6f
2 changed files with 269 additions and 149 deletions

View file

@ -12,6 +12,7 @@ import {
UpdatePropertyCommand,
CommandExecutors,
CommandReceiver,
CharacterMovementSnapshot,
mix,
clamp01,
stepCharacterMovement,
@ -209,10 +210,18 @@ export class CharacterPhysical extends CharacterBase implements DynamicPhysical
return this.currentPlanet;
}
// Persistent launch momentum, streamed to the owning client so its predictor
// can reproduce a leap/slingshot/recoil flight instead of only snapping to it.
public get launchMomentum(): vec2 {
return this.bodyVelocity;
// The continuous movement state streamed to the owning client, so its
// predictor resumes this simulation instead of guessing at the parts of it
// the pose does not show. See CharacterMovementSnapshot.
public get movementSnapshot(): CharacterMovementSnapshot {
return new CharacterMovementSnapshot(
this.direction,
vec2.clone(this.bodyVelocity),
vec2.clone(this.leftFoot.lastNormal),
vec2.clone(this.rightFoot.lastNormal),
this.currentPlanet?.id ?? null,
this.secondsSinceOnSurface,
);
}
public addKill(victimName: string, charge = 0) {

View file

@ -283,7 +283,7 @@ export class Player extends PlayerBase {
this.queueCommandSend(
new InputAcknowledgement(
this.lastInputClientTimeMs,
this.character.launchMomentum,
this.character.movementSnapshot,
this.lastLeapClientTimeMs,
this.lastInputReceiptMs > 0
? Math.max(0, performance.now() - this.lastInputReceiptMs)
@ -369,6 +369,10 @@ export class Player extends PlayerBase {
const sheddable: ReadonlyArray<string> = [
PropertyUpdatesForObjects.type,
UpdateMinimap.type,
// Only meaningful together with the pose it describes, and regenerated
// in full next tick — so it is shed with it rather than advancing the
// client's replay anchor past a snapshot it never received.
InputAcknowledgement.type,
];
this.commandsToBeSent = this.commandsToBeSent.filter(
(c) => !sheddable.includes(c.type),