public override void _PhysicsProcess(float delta) { if (network != default && world != default) { network.PollEvents(); world.Update(); UpdateBandwidth(); // if Input.GetKey... // NetConfig.LatencySimulation = true; void UpdateBandwidth() { bandwidthWindow[framesActive % BANDWIDTH_WINDOW_SIZE] = receivedThisFrame; framesActive++; var sum = 0; foreach (var bytes in bandwidthWindow) { sum += bytes; } var average = sum / (float)BANDWIDTH_WINDOW_SIZE; var kbps = average / delta / 1024.0f; //logger.LogInformation($"framesActive: {framesActive} receivedThisFrame: {receivedThisFrame} KBps: {kbps}"); receivedThisFrame = 0; } } }
void UpdatePlayingState() { clientWorld.Update(); networkClient.SendUserCommands(); LocalTick++; }