Skip to content

Commit

Permalink
fix(LagCompensator): Updated Attributes
Browse files Browse the repository at this point in the history
ServerCallback, DisallowMultipleComponent, and HelpURL
  • Loading branch information
MrGadget1024 committed Mar 28, 2024
1 parent 24883cf commit f2291fc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Assets/Mirror/Components/LagCompensation/LagCompensator.cs
Expand Up @@ -34,7 +34,8 @@ public void DrawGizmo()
public override string ToString() => $"(time={timestamp} pos={position} size={size})";
}

[Obsolete("This is a preview version. Community feedback is welcome!")]
[DisallowMultipleComponent]
[HelpURL("https://mirror-networking.gitbook.io/docs/manual/general/lag-compensation")]
public class LagCompensator : NetworkBehaviour
{
[Header("Components")]
Expand All @@ -51,11 +52,9 @@ public class LagCompensator : NetworkBehaviour
[Header("Debugging")]
public Color historyColor = Color.white;

[ServerCallback]
protected virtual void Update()
{
// only capture on server
if (!NetworkServer.active) return;

// capture lag compensation snapshots every interval.
// NetworkTime.localTime because Unity 2019 doesn't have 'double' time yet.
if (NetworkTime.localTime >= lastCaptureTime + lagCompensationSettings.captureInterval)
Expand All @@ -65,6 +64,7 @@ protected virtual void Update()
}
}

[ServerCallback]
protected virtual void Capture()
{
// capture current state
Expand All @@ -89,7 +89,7 @@ protected virtual void OnDrawGizmos()
// sample the sub-tick (=interpolated) history of this object for a hit test.
// 'viewer' needs to be the player who fired!
// for example, if A fires at B, then call B.Sample(viewer, point, tolerance).
[Server]
[ServerCallback]
public virtual bool Sample(NetworkConnectionToClient viewer, out Capture3D sample)
{
// never trust the client: estimate client time instead.
Expand Down Expand Up @@ -123,7 +123,7 @@ public virtual bool Sample(NetworkConnectionToClient viewer, out Capture3D sampl
// 'viewer' needs to be the player who fired!
// for example, if A fires at B, then call B.Sample(viewer, point, tolerance).
// this is super simple and fast, but not 100% physically accurate since we don't raycast.
[Server]
[ServerCallback]
public virtual bool BoundsCheck(
NetworkConnectionToClient viewer,
Vector3 hitPoint,
Expand Down Expand Up @@ -159,7 +159,7 @@ public virtual bool Sample(NetworkConnectionToClient viewer, out Capture3D sampl
// tolerance: scale up the sampled collider by % in order to have a bit of a tolerance.
// 0 means no extra tolerance, 0.05 means 5% extra tolerance.
// layerMask: the layer mask to use for the raycast.
[Server]
[ServerCallback]
public virtual bool RaycastCheck(
NetworkConnectionToClient viewer,
Vector3 originPoint,
Expand Down

0 comments on commit f2291fc

Please sign in to comment.