RealDocs

APlayerState::RecalculateAvgPing

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: virtualENGINE_API

Description

Computes the rolling average ping from the accumulated bucket data and writes it to ExactPing and (if bShouldUpdateReplicatedPing is true) CompressedPing. Called once per second by the engine.

Caveats & Gotchas

  • Uses a 4-second rolling window divided into four 1-second buckets. Old buckets are weighted less than recent ones, but the algorithm means a single ping spike can affect the average for up to 4 seconds.
  • Do not call this manually unless you have overridden the ping update cadence. Calling it more frequently than once per second only re-reads the same bucket data without new measurements, producing no improvement.

Signature

ENGINE_API virtual void RecalculateAvgPing();

Return Type

void

Example

Override to apply custom smoothing C++
void AMyPlayerState::RecalculateAvgPing()
{
    Super::RecalculateAvgPing();
    // ExactPing now holds the recalculated average; apply smoothing on top
    SmoothedPing = FMath::FInterpTo(SmoothedPing, ExactPing, GetWorld()->GetDeltaSeconds(), 5.0f);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.