void Update() { if (!TickEngineSettings.single.enableTickEngine) { return; } if (simulationHasRun) { PostSimulate(); } DoubleTime.SnapUpdate(); NormTimeSinceFixed = (Time.time - Time.fixedTime) / Time.fixedDeltaTime; NetMasterCallbacks.OnPreUpdateCallbacks(); float t = (Time.time - lastSentTickTime) / (TickEngineSettings.netTickInterval); // Interpolate NetObjects NetObject.NetObjDictsLocked = true; foreach (var no in NetObject.activeUncontrolledNetObjs.Values) { no.OnInterpolate(_prevFrameId, _currFrameId, t); } NetObject.NetObjDictsLocked = false; // Interpolate Others NetMasterCallbacks.OnInterpolateCallbacks(_prevFrameId, _currFrameId, t); }
private void FixedUpdate() { /// Disable Simple if no NetObjects exist. if (NetObject.activeControlledNetObjs.Count == 0 && NetObject.activeUncontrolledNetObjs.Count == 0) { return; } if (!TickEngineSettings.single.enableTickEngine) { return; } /// Halt everything if networking isn't ready. bool readyToSend = NetMsgSends.ReadyToSend; if (!readyToSend) { DoubleTime.SnapFixed(); return; } if (simulationHasRun) { PostSimulate(); } DoubleTime.SnapFixed(); #if PUN_2_OR_NEWER /// Make sure we don't have any incoming messages. PUN checks this pre-Update but not so explicitly at the top of the fixed. /// We want to ensure that we are running our simulation with the most current network input/states so best to make sure we have all that is available. /// Make sure Photon isn't holding out on us just because a FixedUpdate didn't happen this Update() bool doDispatch = true; while (PhotonNetwork.InRoom && PhotonNetwork.IsMessageQueueRunning && doDispatch) { // DispatchIncomingCommands() returns true of it found any command to dispatch (event, result or state change) doDispatch = PhotonNetwork.NetworkingClient.LoadBalancingPeer.DispatchIncomingCommands(); } rtt = PhotonNetwork.GetPing() * .001f; #endif simulationHasRun = true; }