void Awake() { singleton = this; settings = networkSettings; sendUpdates = Mathf.Max(1, Mathf.RoundToInt(settings.sendRate / Time.fixedDeltaTime)); sendDiv = 1f / (float)sendUpdates; }
void Update() { curtime = Time.fixedTime; frametime = Time.deltaTime; //Can happen on script reload if (settings == null) { settings = networkSettings; } if (!Extensions.AlmostEquals(sendUpdates * sendDiv, 1f, 0.01f)) { sendUpdates = Mathf.Max(1, Mathf.RoundToInt(settings.sendRate / Time.fixedDeltaTime)); sendDiv = 1f / (float)sendUpdates; } if (!settings.useFixedUpdate) { DispatchTicks(); } //TODO: store a local player reference and do without looping the list for (int i = 0; i < players.Count; i++) { if (!players[i].destroyed) { players[i].controller.UpdateInputs(); } } }
void FixedUpdate() { curtime = Time.fixedTime; if (settings == null) { settings = networkSettings; } if (settings.useFixedUpdate) { DispatchTicks(); } }