Vixen
02b45cc4
csharp
public sealed class OwnerSmoothing

Hides the server correcting the local player, without lying about where they are.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The owner of an object does not interpolate it — they simulate it, from their own input, on the frame they pressed the key. That is the whole reason a local player feels responsive and everyone else looks smooth, and it is why owner-side motion is a different problem from SnapshotBuffer's.

But the server is the authority, so sometimes it says the player is somewhere else. Moving them there is correct and looks like a twitch. So the simulation takes the correction immediately — the next physics step, the next hit test and everything the server will judge all run from the right place — and the camera is given the error as an offset that decays away over a few frames. What the player sees glides; what the game computes is already right.

Past SnapDistance there is no gliding: a correction that large is a respawn or a rubber-band, and dragging the camera across the map is worse than putting it there.

Fields and properties (6)

  • public TimeSpan HalfLife

    How long the visible half of an error takes to disappear.

  • public float SnapDistance

    How large a correction stops being smoothed and is simply shown.

  • public Vector3 Error

    What is still being worked off.

  • public bool IsSmoothing

    Whether anything is being worked off right now.

  • public long CorrectionCount

    Corrections taken.

  • public long SnapCount

    Corrections too large to smooth, which were shown instead.

Methods (3)

  • public void Correct(in Vector3 from, in Vector3 to)

    Takes a correction: the simulation is about to move from one place to another, and this is what the eye should not see happen all at once.

  • public Vector3 Apply(in Vector3 simulated, TimeSpan elapsed)

    Where to draw the owner this frame.

  • public void Reset()

    Drops what is being worked off, for an object that has just been put somewhere.

Used by (2)

  • MotionTestsVixen.Net.Tests
  • PredictionSmootherVixen.Net