p.NetUsePackedMovementRPCs
p.NetUsePackedMovementRPCs
#Overview
name: p.NetUsePackedMovementRPCs
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use newer movement RPC parameter packed serialization. If disabled, old deprecated movement RPCs will be used instead.\n0: Disable, 1: Enable
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.NetUsePackedMovementRPCs is to control whether the Unreal Engine uses newer movement RPC parameter packed serialization for character movement in networked games. This setting is primarily used in the character movement system.
The Unreal Engine subsystem that relies on this setting variable is the character movement component, which is part of the engine’s gameplay framework. This can be seen from the references in the CharacterMovementComponent.cpp and CharacterMovementComponent.h files.
The value of this variable is set through a console variable (cvar) using FAutoConsoleVariableRef. It is initialized to 1 (enabled) by default but can be changed at runtime through the console or configuration files.
This variable interacts closely with NetUsePackedMovementRPCs, which is the actual integer variable that stores the value. The p.NetUsePackedMovementRPCs is the console variable name that allows external access to this setting.
Developers must be aware that this variable affects how character movement data is serialized and sent over the network. When enabled (set to 1), it uses a newer, more efficient packed serialization method. When disabled (set to 0), it falls back to older, deprecated movement RPCs.
Best practices when using this variable include:
- Generally keeping it enabled (1) for better network performance and flexibility.
- Only disabling it if there are specific compatibility issues with older code or custom implementations that rely on the deprecated RPCs.
- Being consistent across all clients and the server in a networked game to avoid desynchronization issues.
Regarding the associated variable NetUsePackedMovementRPCs:
The purpose of NetUsePackedMovementRPCs is to store the actual value that determines whether packed movement RPCs are used. It’s the backing variable for the p.NetUsePackedMovementRPCs console variable.
This variable is used directly in the CharacterMovementComponent to determine whether to use packed movement RPCs through the ShouldUsePackedMovementRPCs() function.
The value of this variable is set by the console variable system when p.NetUsePackedMovementRPCs is modified.
It interacts with other movement-related variables like NetUseBaseRelativeAcceleration and NetUseBaseRelativeVelocity, which are also part of the character movement system.
Developers should be aware that this variable is accessed through the CharacterMovementCVars namespace, indicating it’s part of a group of related character movement console variables.
Best practices include using the ShouldUsePackedMovementRPCs() function to check this value rather than accessing the variable directly, as this provides a layer of abstraction and allows for potential future changes in how the decision is made.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:108
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
static int32 NetUsePackedMovementRPCs = 1;
FAutoConsoleVariableRef CVarNetUsePackedMovementRPCs(
TEXT("p.NetUsePackedMovementRPCs"),
NetUsePackedMovementRPCs,
TEXT("Whether to use newer movement RPC parameter packed serialization. If disabled, old deprecated movement RPCs will be used instead.\n")
TEXT("0: Disable, 1: Enable"),
ECVF_Default);
static int32 NetPackedMovementMaxBits = 4096;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/CharacterMovementComponent.h:2455
Scope: file
Source code excerpt:
/**
* Determines whether to use packed movement RPCs with variable length payloads, or legacy code which has multiple functions required for different situations.
* The default implementation checks the console variable "p.NetUsePackedMovementRPCs" and returns true if it is non-zero.
*/
ENGINE_API virtual bool ShouldUsePackedMovementRPCs() const;
/* Sends a move response from the server to the client (through character to avoid component RPC overhead), eventually calling MoveResponsePacked_ClientReceive() on the client. */
ENGINE_API void MoveResponsePacked_ServerSend(const FCharacterMoveResponsePackedBits& PackedBits);
/* On the client, receives a packed move response from the server, unpacks it by serializing into the MoveResponseContainer from GetMoveResponseDataContainer(), and passes the data container to ClientHandleMoveResponse(). */
ENGINE_API void MoveResponsePacked_ClientReceive(const FCharacterMoveResponsePackedBits& PackedBits);
#Associated Variable and Callsites
This variable is associated with another variable named NetUsePackedMovementRPCs
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:106
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
{
// Use newer RPCs and RPC parameter serialization that allow variable length data without changing engine APIs.
static int32 NetUsePackedMovementRPCs = 1;
FAutoConsoleVariableRef CVarNetUsePackedMovementRPCs(
TEXT("p.NetUsePackedMovementRPCs"),
NetUsePackedMovementRPCs,
TEXT("Whether to use newer movement RPC parameter packed serialization. If disabled, old deprecated movement RPCs will be used instead.\n")
TEXT("0: Disable, 1: Enable"),
ECVF_Default);
static int32 NetPackedMovementMaxBits = 4096;
FAutoConsoleVariableRef CVarNetPackedMovementMaxBits(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:250
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
* Enabling this will produce better motion when walking on highly dynamic / unpredictable movement bases, such as vehicles. However, there is the potential for larger corrections when landing on or jumping off if the base's rotation is not well-sync'd.
* This also may be a good option if using dynamic movement bases that become the player's primary frame of visual reference, such as when walking on a large boat or airship.
* Not compatible with deprecated move RPCs. @see NetUsePackedMovementRPCs
*/
static int32 NetUseBaseRelativeAcceleration = 1;
FAutoConsoleVariableRef CVarNetUseBaseRelativeAcceleration(
TEXT("p.NetUseBaseRelativeAcceleration"),
NetUseBaseRelativeAcceleration,
TEXT("If enabled, character acceleration will be treated as relative to dynamic movement bases."));
static int32 NetUseBaseRelativeVelocity = 1;
FAutoConsoleVariableRef CVarNetUseBaseRelativeVelocity(
TEXT("p.NetUseBaseRelativeVelocity"),
NetUseBaseRelativeVelocity,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:985
Scope (from outer to inner):
file
function bool UCharacterMovementComponent::ShouldUsePackedMovementRPCs
Source code excerpt:
bool UCharacterMovementComponent::ShouldUsePackedMovementRPCs() const
{
return CharacterMovementCVars::NetUsePackedMovementRPCs != 0;
}
FCollisionShape UCharacterMovementComponent::GetPawnCapsuleCollisionShape(const EShrinkCapsuleExtent ShrinkMode, const float CustomShrinkAmount) const
{
FVector Extent = GetPawnCapsuleExtent(ShrinkMode, CustomShrinkAmount);
return FCollisionShape::MakeCapsule(Extent);