Skip to content

Instantly share code, notes, and snippets.

@314pies
Created September 12, 2018 10:17
Show Gist options
  • Save 314pies/c9a63819051697846fc0f05a21afd56e to your computer and use it in GitHub Desktop.
Save 314pies/c9a63819051697846fc0f05a21afd56e to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SmoothSyncTest : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine(NetworkSyncEmulating());
}
[SerializeField]
private float SyncRate = 0.1f;
[SerializeField]
private float MinLatency=0.03f, MaxLatency = 0.3f;
IEnumerator NetworkSyncEmulating()
{
while (true)
{
yield return new WaitForSeconds(SyncRate + Random.Range(MinLatency, MaxLatency));
Debug.Log("Position Sync.");
//Invoke your synchronize method here
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment