mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
LatencySimulation: spike latency via multiplier
This commit is contained in:
parent
1281f72ac2
commit
83f8593caa
@ -21,6 +21,10 @@ public class LatencySimulation : Transport
|
||||
{
|
||||
public Transport wrap;
|
||||
|
||||
[Header("Common")]
|
||||
[Tooltip("Spike latency via Sin(Time) * multiplier")]
|
||||
public float latencySineMultiplier;
|
||||
|
||||
[Header("Reliable Messages")]
|
||||
[Tooltip("Reliable latency in seconds")]
|
||||
public float reliableLatency;
|
||||
@ -63,12 +67,16 @@ public void Awake()
|
||||
// helper function to simulate latency
|
||||
float SimulateLatency(int channeldId)
|
||||
{
|
||||
// spike over sine
|
||||
float spike = (float)Math.Sin(Time.time) * latencySineMultiplier;
|
||||
|
||||
// base latency
|
||||
switch (channeldId)
|
||||
{
|
||||
case Channels.Reliable:
|
||||
return reliableLatency;
|
||||
return reliableLatency + spike;
|
||||
case Channels.Unreliable:
|
||||
return unreliableLatency;
|
||||
return unreliableLatency + spike;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user