demo.RecordHzWhenNotRelevant

demo.RecordHzWhenNotRelevant

#Overview

name: demo.RecordHzWhenNotRelevant

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of demo.RecordHzWhenNotRelevant is to control the frequency at which actors are recorded in a demo (replay) when they are not considered relevant. This setting is part of Unreal Engine’s demo recording and playback system.

This setting variable is primarily used in the Unreal Engine’s networking and demo recording subsystem. Based on the callsites, it’s specifically utilized in the DemoNetDriver module, which is responsible for managing network demo recording and playback.

The value of this variable is set as a console variable with a default value of 2.0f. It can be modified at runtime through the console or configuration files.

The variable interacts with other demo-related variables, particularly those controlling relevancy checks and distance culling for actors in demo recordings. It’s closely associated with CVarDemoRecordHzWhenNotRelevant, which shares the same value and purpose.

Developers must be aware that this variable affects performance and file size of demo recordings. A higher value will result in more frequent updates for non-relevant actors, potentially increasing file size and processing overhead. Conversely, a lower value may lead to less accurate representations of non-relevant actors in the replay.

Best practices when using this variable include:

  1. Balancing between replay accuracy and performance/file size.
  2. Considering the nature of your game and how important non-relevant actors are to the overall replay experience.
  3. Testing different values to find the optimal setting for your specific use case.

Regarding the associated variable CVarDemoRecordHzWhenNotRelevant:

This is the actual console variable that stores the value for demo.RecordHzWhenNotRelevant. It’s defined as a static TAutoConsoleVariable of type float, with a default value of 2.0f.

The purpose of CVarDemoRecordHzWhenNotRelevant is identical to demo.RecordHzWhenNotRelevant - it controls the frequency of recording non-relevant actors in demo recordings.

This variable is used in the UDemoNetDriver::TickDemoRecordFrame function to calculate the update delay for non-relevant actors. The calculated delay is then used to determine when the next update for a non-relevant actor should occur.

Developers should be aware that changing this value at runtime will affect the behavior of demo recordings in progress. It’s important to set this value appropriately before starting a demo recording for consistent results.

Best practices for using CVarDemoRecordHzWhenNotRelevant include:

  1. Documenting any changes to this value in your project settings or configuration files.
  2. Considering the impact on both recording and playback performance when adjusting this value.
  3. Testing the effects of different values on demo file size and playback quality to find the optimal setting for your game.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:157, section: [ConsoleVariables]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:63

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));

static TAutoConsoleVariable<int32> CVarDemoJumpToEndOfLiveReplay(TEXT("demo.JumpToEndOfLiveReplay"), 1, TEXT("If true, fast forward to a few seconds before the end when starting playback, if the replay is still being recorded."));
static TAutoConsoleVariable<int32> CVarDemoInternalPauseChannels(TEXT("demo.InternalPauseChannels"), 1, TEXT("If true, run standard logic for PauseChannels rather than letting the game handle it via FOnPauseChannelsDelegate."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2039

Scope (from outer to inner):

file
function     void UDemoNetDriver::TickDemoRecordFrame

Source code excerpt:

					if (!bIsRelevant && !bWasRecentlyRelevant)
					{
						// Actor is not relevant (or previously relevant), so skip and set next update time based on demo.RecordHzWhenNotRelevant
						ActorInfo->NextUpdateTime = CurrentTime + UpdateDelayWhenNotRelevant;
						continue;
					}

					UActorChannel* Channel = nullptr;
					if (bDoFindActorChannelEarly)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:63

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));

static TAutoConsoleVariable<int32> CVarDemoJumpToEndOfLiveReplay(TEXT("demo.JumpToEndOfLiveReplay"), 1, TEXT("If true, fast forward to a few seconds before the end when starting playback, if the replay is still being recorded."));
static TAutoConsoleVariable<int32> CVarDemoInternalPauseChannels(TEXT("demo.InternalPauseChannels"), 1, TEXT("If true, run standard logic for PauseChannels rather than letting the game handle it via FOnPauseChannelsDelegate."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1963

Scope (from outer to inner):

file
function     void UDemoNetDriver::TickDemoRecordFrame

Source code excerpt:

			const float CullDistanceOverrideSq = CullDistanceOverride > 0.0f ? FMath::Square(CullDistanceOverride) : 0.0f;

			const float RecordHzWhenNotRelevant = CVarDemoRecordHzWhenNotRelevant.GetValueOnAnyThread();
			const float UpdateDelayWhenNotRelevant = RecordHzWhenNotRelevant > 0.0f ? 1.0f / RecordHzWhenNotRelevant : 0.5f;

			TArray<AActor*, TInlineAllocator<128>> ActorsToRemove;

			FDemoActorPriority DemoActorPriority;
			FActorPriority& ActorPriority = DemoActorPriority.ActorPriority;