RealDocs

APlayerState::UpdatePing

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

Description

Receives a new ping measurement from the net driver and accumulates it into the rolling ping bucket for averaging. Called frequently by the engine — not intended for direct use.

Caveats & Gotchas

  • InPing is in seconds, not milliseconds. The engine multiplies by 1000 and passes through the rolling average to produce the final GetPingInMilliseconds() value. Passing an already-converted millisecond value will produce inflated readings.
  • This is called much more frequently on the client side (where the client measures its own RTT) than on the server side, so client-side and server-side displayed pings will often differ.

Signature

ENGINE_API virtual void UpdatePing(float InPing);

Parameters

Name Type Description Default
InPing float The latest round-trip time measurement in seconds.

Return Type

void

Example

Override to clamp extreme ping values C++
void AMyPlayerState::UpdatePing(float InPing)
{
    // Clamp to 2 seconds maximum to discard timeout spikes
    Super::UpdatePing(FMath::Min(InPing, 2.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.