AbilitySystem.ReplicateMontageNextSectionId
AbilitySystem.ReplicateMontageNextSectionId
#Overview
name: AbilitySystem.ReplicateMontageNextSectionId
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Apply the replicated next section Id to montages when skipping position replication
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of AbilitySystem.ReplicateMontageNextSectionId is to control whether the replicated next section ID should be applied to montages when skipping position replication in the Gameplay Ability System.
This setting variable is primarily used in the Gameplay Abilities plugin, which is part of Unreal Engine’s ability system. It specifically affects the replication of animation montages within this system.
The value of this variable is set as a console variable (CVar) in the Unreal Engine. It’s initialized with a default value of true, but can be changed at runtime through console commands or project settings.
This variable interacts closely with the AnimInstance and montage playback system. It’s used in conjunction with other variables related to montage replication, such as CVarUpdateMontageSectionIdToPlay and CVarGasFixClientSideMontageBlendOutTime.
Developers must be aware that this variable affects network replication behavior. When enabled, it ensures that clients receive and apply the correct next section ID for montages, even when position replication is skipped. This can be crucial for maintaining synchronization between server and client in ability-driven animations.
Best practices when using this variable include:
- Ensuring it’s enabled when precise montage section synchronization is required across the network.
- Testing the game thoroughly with this setting both enabled and disabled to understand its impact on your specific implementation.
- Considering performance implications, as additional replication may increase network traffic.
Regarding the associated variable CVarReplicateMontageNextSectionId:
This is the actual console variable that controls the behavior described above. It’s defined using TAutoConsoleVariable
The purpose of CVarReplicateMontageNextSectionId is identical to AbilitySystem.ReplicateMontageNextSectionId, as they refer to the same setting.
It’s used in the UAbilitySystemComponent class, specifically in the OnRep_ReplicatedAnimMontage function. This function handles the replication of animation montages in the ability system.
When using this variable, developers should be aware that it’s checked using GetValueOnAnyThread(), which means its value can be accessed from any thread. This is important for thread-safety considerations in multithreaded game code.
Best practices for CVarReplicateMontageNextSectionId include:
- Using it as a debugging tool to toggle this behavior on and off during development.
- Considering exposing it as a configurable option in your game’s settings if fine-tuning of network behavior is necessary.
- Documenting its usage and impact clearly for other team members working on the ability system or animation replication.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemComponent_Abilities.cpp:50
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarGasFixClientSideMontageBlendOutTime(TEXT("AbilitySystem.Fix.ClientSideMontageBlendOutTime"), true, TEXT("Enable a fix to replicate the Montage BlendOutTime for (recently) stopped Montages"));
static TAutoConsoleVariable<bool> CVarUpdateMontageSectionIdToPlay(TEXT("AbilitySystem.UpdateMontageSectionIdToPlay"), true, TEXT("During tick, update the section ID that replicated montages should use"));
static TAutoConsoleVariable<bool> CVarReplicateMontageNextSectionId(TEXT("AbilitySystem.ReplicateMontageNextSectionId"), true, TEXT("Apply the replicated next section Id to montages when skipping position replication"));
static TAutoConsoleVariable<bool> CVarEnsureAbilitiesEndGracefully(TEXT("AbilitySystem.EnsureAbilitiesEndGracefully"), true, TEXT("When shutting down (during ClearAllAbilities) we should check if all GameplayAbilities gracefully ended. This should be disabled if you have NonInstanced abilities that are designed for multiple concurrent executions."));
void UAbilitySystemComponent::InitializeComponent()
{
Super::InitializeComponent();
#Associated Variable and Callsites
This variable is associated with another variable named CVarReplicateMontageNextSectionId
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemComponent_Abilities.cpp:50
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarGasFixClientSideMontageBlendOutTime(TEXT("AbilitySystem.Fix.ClientSideMontageBlendOutTime"), true, TEXT("Enable a fix to replicate the Montage BlendOutTime for (recently) stopped Montages"));
static TAutoConsoleVariable<bool> CVarUpdateMontageSectionIdToPlay(TEXT("AbilitySystem.UpdateMontageSectionIdToPlay"), true, TEXT("During tick, update the section ID that replicated montages should use"));
static TAutoConsoleVariable<bool> CVarReplicateMontageNextSectionId(TEXT("AbilitySystem.ReplicateMontageNextSectionId"), true, TEXT("Apply the replicated next section Id to montages when skipping position replication"));
static TAutoConsoleVariable<bool> CVarEnsureAbilitiesEndGracefully(TEXT("AbilitySystem.EnsureAbilitiesEndGracefully"), true, TEXT("When shutting down (during ClearAllAbilities) we should check if all GameplayAbilities gracefully ended. This should be disabled if you have NonInstanced abilities that are designed for multiple concurrent executions."));
void UAbilitySystemComponent::InitializeComponent()
{
Super::InitializeComponent();
#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemComponent_Abilities.cpp:3287
Scope (from outer to inner):
file
function void UAbilitySystemComponent::OnRep_ReplicatedAnimMontage
Source code excerpt:
constexpr bool bForceGameThreadValue = true;
if (CVarReplicateMontageNextSectionId.GetValueOnAnyThread(bForceGameThreadValue))
{
const int32 NextSectionID = AnimInstance->Montage_GetNextSectionID(LocalAnimMontageInfo.AnimMontage, CurrentSectionID);
const int32 RepNextSectionID = int32(ConstRepAnimMontageInfo.NextSectionID) - 1;
// If NextSectionID is different than the replicated one, then set it.
if (RepNextSectionID != INDEX_NONE && NextSectionID != RepNextSectionID)