From 62a1d225286c293f397f2ea0b0885ebe8b2a39f8 Mon Sep 17 00:00:00 2001 From: APEX FIGHT Date: Fri, 3 Jan 2025 00:33:48 -0500 Subject: [PATCH] added tick interval options (to reduce network load from 80tps lololol) --- Client/Unity/CSNC.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Client/Unity/CSNC.cs b/Client/Unity/CSNC.cs index 4ce2cd7..6ef2363 100644 --- a/Client/Unity/CSNC.cs +++ b/Client/Unity/CSNC.cs @@ -6,9 +6,10 @@ using UnityEngine.Networking; public class CSNC : MonoBehaviour { + public float tickInterval = 5f; // x times per sec public string ip; public GameObjectManager manager; - + private float lastPing = 0; //last time connected to server public class EZtransform //ez consistent serialization of transforms { @@ -79,8 +80,12 @@ public class CSNC : MonoBehaviour void FixedUpdate() { - IEnumerator req = request(); - StartCoroutine(req); + if (Time.timeSinceLevelLoad - (1000f / tickInterval) > lastPing) + { + lastPing = Time.timeSinceLevelLoad; + IEnumerator req = request(); + StartCoroutine(req); + } } IEnumerator request() {