PlayerController.NetResetServerPredictionDataOnPawnAck

PlayerController.NetResetServerPredictionDataOnPawnAck

#Overview

name: PlayerController.NetResetServerPredictionDataOnPawnAck

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PlayerController.NetResetServerPredictionDataOnPawnAck is to control whether the server resets prediction data for the possessed Pawn when the pawn acknowledgment handshake completes. This setting is primarily used in the networking and player control systems of Unreal Engine 5.

This setting variable is relied upon by the Engine module, specifically within the PlayerController class. It’s used to manage server-side prediction for player-controlled pawns in networked games.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. By default, it is enabled (set to 1).

The associated variable NetResetServerPredictionDataOnPawnAck interacts directly with this setting. They share the same value and purpose.

Developers should be aware that this variable affects the behavior of server-side prediction in multiplayer games. When enabled, it causes the server to reset prediction data for a pawn when the client acknowledges possession of that pawn. This can help ensure that the server and client are synchronized, potentially reducing movement discrepancies.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) unless you have a specific reason to disable it.
  2. If you’re experiencing issues with player movement prediction in multiplayer games, you might want to experiment with disabling this feature to see if it improves the situation.
  3. Be cautious when modifying this value, as it can affect the accuracy of player movement prediction and potentially introduce networking issues if not handled correctly.

Regarding the associated variable NetResetServerPredictionDataOnPawnAck:

This is the actual integer variable that stores the setting value. It’s defined within the PlayerControllerCVars namespace and is used directly in the ServerAcknowledgePossession_Implementation function of the APlayerController class.

The purpose and usage of this associated variable are identical to the console variable. It determines whether the server should reset prediction data when a pawn is acknowledged. When this value is non-zero, the server will attempt to reset prediction data for the acknowledged pawn if it matches the current pawn and has a movement component that implements the INetworkPredictionInterface.

Developers should be aware that modifying this variable directly in code will have the same effect as changing the console variable. It’s generally better to use the console variable for runtime adjustments and debugging, while this associated variable can be used for hardcoded logic if necessary.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:93

Scope (from outer to inner):

file
namespace    PlayerControllerCVars

Source code excerpt:

	static int32 NetResetServerPredictionDataOnPawnAck = 1;
	FAutoConsoleVariableRef CVarNetResetServerPredictionDataOnPawnAck(
		TEXT("PlayerController.NetResetServerPredictionDataOnPawnAck"),
		NetResetServerPredictionDataOnPawnAck,
		TEXT("Whether to reset server prediction data for the possessed Pawn when the pawn ack handshake completes.\n")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Default);

	static int32 ForceUsingCameraAsStreamingSource = 0;

#Associated Variable and Callsites

This variable is associated with another variable named NetResetServerPredictionDataOnPawnAck. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:91

Scope (from outer to inner):

file
namespace    PlayerControllerCVars

Source code excerpt:

{
	// Resync timestamps on pawn ack
	static int32 NetResetServerPredictionDataOnPawnAck = 1;
	FAutoConsoleVariableRef CVarNetResetServerPredictionDataOnPawnAck(
		TEXT("PlayerController.NetResetServerPredictionDataOnPawnAck"),
		NetResetServerPredictionDataOnPawnAck,
		TEXT("Whether to reset server prediction data for the possessed Pawn when the pawn ack handshake completes.\n")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Default);

	static int32 ForceUsingCameraAsStreamingSource = 0;
	FAutoConsoleVariableRef CVarForceUsingCameraAsStreamingSource(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:1284

Scope (from outer to inner):

file
function     void APlayerController::ServerAcknowledgePossession_Implementation

Source code excerpt:

	AcknowledgedPawn = P;

	if (PlayerControllerCVars::NetResetServerPredictionDataOnPawnAck != 0)
	{
		if (AcknowledgedPawn && AcknowledgedPawn == GetPawn())
		{
			INetworkPredictionInterface* NetworkPredictionInterface = GetPawn() ? Cast<INetworkPredictionInterface>(GetPawn()->GetMovementComponent()) : NULL;
			if (NetworkPredictionInterface)
			{