This commit is contained in:
2025-12-02 18:48:32 +08:00
parent 92ba80b399
commit bf1ca60b3b
2357 changed files with 262694 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
// a simple snapshot with timestamp & interpolation
using UnityEngine;
namespace Mirror.Examples.LagCompensationDemo
{
public struct Snapshot3D : Snapshot
{
public double remoteTime { get; set; }
public double localTime { get; set; }
public Vector3 position;
public Snapshot3D(double remoteTime, double localTime, Vector3 position)
{
this.remoteTime = remoteTime;
this.localTime = localTime;
this.position = position;
}
public static Snapshot3D Interpolate(Snapshot3D from, Snapshot3D to, double t) =>
new Snapshot3D(
// interpolated snapshot is applied directly. don't need timestamps.
0, 0,
// lerp unclamped in case we ever need to extrapolate.
Vector3.LerpUnclamped(from.position, to.position, (float)t));
}
}