mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix(LagCompensator): Updated Attributes
ServerCallback, DisallowMultipleComponent, and HelpURL
This commit is contained in:
parent
24883cfe02
commit
f2291fc5a8
@ -34,7 +34,8 @@ public static Capture3D Interpolate(Capture3D from, Capture3D to, double t) =>
|
||||
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")]
|
||||
@ -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)
|
||||
@ -65,6 +64,7 @@ protected virtual void Update()
|
||||
}
|
||||
}
|
||||
|
||||
[ServerCallback]
|
||||
protected virtual void Capture()
|
||||
{
|
||||
// capture current state
|
||||
@ -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.
|
||||
@ -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,
|
||||
@ -159,7 +159,7 @@ public virtual bool BoundsCheck(
|
||||
// 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,
|
||||
|
Loading…
Reference in New Issue
Block a user