diff --git a/Assets/Scripts/Api/ApiManager.cs b/Assets/Scripts/Api/ApiManager.cs index a773efc0b..f94237496 100644 --- a/Assets/Scripts/Api/ApiManager.cs +++ b/Assets/Scripts/Api/ApiManager.cs @@ -590,30 +590,36 @@ void FixedUpdate() return; } - if (ApiLock.IsUnlocked && Time.timeScale != 0.0f) + if (!ApiLock.IsUnlocked || Time.timeScale == 0.0f) { - if (FrameLimit != 0 && CurrentFrame >= FrameLimit) + return; + } + + if (FrameLimit != 0) + { + if (CurrentFrame >= FrameLimit) { // pause and notify API SimulatorManager.SetTimeScale(0.0f); SendResult(); + return; } - else - { - if (FrameLimit == 0 && !API_Notified) - { - SendResult(); - API_Notified = true; - } - CurrentTime += Time.fixedDeltaTime; - CurrentFrame += 1; + } + else if (!API_Notified) + { + SendResult(); + API_Notified = true; + } - if (!CurrentSceneId.IsNullOrEmpty()) - { - SimulatorManager.Instance.PhysicsUpdate(); - } - } + CurrentTime += Time.fixedDeltaTime; + CurrentFrame += 1; + + if (CurrentSceneId.IsNullOrEmpty()) + { + return; } + + SimulatorManager.Instance.PhysicsUpdate(); } public void ReceiveMessage(IPeerManager sender, DistributedMessage distributedMessage)