diff --git a/MLAPI/MonoBehaviours/Core/LagCompensationManager.cs b/MLAPI/MonoBehaviours/Core/LagCompensationManager.cs index 3541283..ae54ff0 100644 --- a/MLAPI/MonoBehaviours/Core/LagCompensationManager.cs +++ b/MLAPI/MonoBehaviours/Core/LagCompensationManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using UnityEngine; using UnityEngine.Networking; namespace MLAPI.MonoBehaviours.Core @@ -10,6 +11,11 @@ namespace MLAPI.MonoBehaviours.Core public static void Simulate(float secondsAgo, Action action) { + if(!NetworkingManager.singleton.isServer) + { + Debug.LogWarning("MLAPI: Lag compensation simulations are only to be ran on the server."); + return; + } for (int i = 0; i < SimulationObjects.Count; i++) { SimulationObjects[i].ReverseTransform(secondsAgo); @@ -26,6 +32,11 @@ namespace MLAPI.MonoBehaviours.Core private static byte error = 0; public static void Simulate(int clientId, Action action) { + if (!NetworkingManager.singleton.isServer) + { + Debug.LogWarning("MLAPI: Lag compensation simulations are only to be ran on the server."); + return; + } float milisecondsDelay = NetworkTransport.GetCurrentRTT(NetworkingManager.singleton.hostId, clientId, out error) / 2f; Simulate(milisecondsDelay * 1000f, action); } diff --git a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs index 2f64b7c..1fd93ee 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs @@ -329,7 +329,8 @@ namespace MLAPI (messagesProcessed < NetworkConfig.MaxMessagesPerFrame || NetworkConfig.MaxMessagesPerFrame < 0)); } - LagCompensationManager.AddFrames(); + if (isServer) + LagCompensationManager.AddFrames(); } private IEnumerator ApprovalTimeout(int clientId)