APlayerState::GetPingInMilliseconds
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableENGINE_API
Description
Returns the player's ping in milliseconds. Uses ExactPing for local players and the server, and falls back to the replicated CompressedPing (decompressed) on remote clients.
Caveats & Gotchas
- • CompressedPing stores ping divided by 4, so the replicated value has a precision of ±4ms. ExactPing is only available on the server or for local players.
- • If bShouldUpdateReplicatedPing is false on the PlayerState, this will return 0 or a stale value on clients for remote players. The default is true, but it can be disabled to reduce replication overhead in large player-count games.
Signature
ENGINE_API float GetPingInMilliseconds() const; Return Type
float Example
Display ping in HUD C++
FString AMyHUD::GetPingText(APlayerState* PS) const
{
if (!PS) return TEXT("--");
return FString::Printf(TEXT("%d ms"), FMath::RoundToInt(PS->GetPingInMilliseconds()));
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?