demo.FastForwardDestroyTearOffActors

demo.FastForwardDestroyTearOffActors

#Overview

name: demo.FastForwardDestroyTearOffActors

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 demo.FastForwardDestroyTearOffActors is to control the behavior of torn-off actors during the fast-forwarding of a replay in Unreal Engine’s demo system.

This setting variable is primarily used in the demo replay system, which is part of Unreal Engine’s networking subsystem. It’s specifically related to the UDemoNetDriver class, which handles the recording and playback of network demos.

The value of this variable is set as a console variable (CVar) in the engine’s initialization code. It’s defined with a default value of 1 (true) and can be changed at runtime through console commands or configuration files.

The main variable that interacts with it is CVarDemoFastForwardDestroyTearOffActors, which is the actual TAutoConsoleVariable instance that holds the value. This variable is used in the UDemoNetDriver::ShouldClientDestroyTearOffActors() function to determine whether torn-off actors should be immediately destroyed during fast-forwarding.

Developers should be aware that:

  1. This setting affects performance and memory usage during replay fast-forwarding.
  2. When enabled (set to 1), it will cause torn-off actors to be destroyed immediately during fast-forward, which can improve performance but might affect the accuracy of the replay if those actors are needed later.
  3. Disabling this (set to 0) will keep torn-off actors alive during fast-forward, which might be necessary for some gameplay scenarios but could impact performance.

Best practices when using this variable:

  1. Leave it enabled (default value of 1) unless you have specific reasons to keep torn-off actors during fast-forward.
  2. If you’re developing a game with complex actor interactions that persist after being torn off, you might need to disable this feature and handle the performance implications separately.
  3. Test your replays thoroughly with both settings to ensure that your game behaves correctly in all scenarios.

Regarding the associated variable CVarDemoFastForwardDestroyTearOffActors:

This is the actual TAutoConsoleVariable instance that holds the value for the demo.FastForwardDestroyTearOffActors setting. It’s defined in the same file (DemoNetDriver.cpp) and is used directly in the code to check the current setting value.

The purpose of this variable is the same as demo.FastForwardDestroyTearOffActors, but it’s the C++ implementation that the engine code interacts with directly.

It’s used in the UDemoNetDriver::ShouldClientDestroyTearOffActors() function to determine the behavior of torn-off actors during fast-forwarding. This function likely gets called during the replay playback process to decide whether to destroy certain actors.

Developers should be aware that changing this variable at runtime will immediately affect the behavior of the demo playback system. It’s important to ensure that any code relying on the state of torn-off actors during replay is aware of and can handle both possible values of this setting.

Best practices for using CVarDemoFastForwardDestroyTearOffActors include:

  1. Use the GetValueOnGameThread() method to access its value, as shown in the provided code snippet.
  2. Consider the performance and gameplay implications when deciding to change this value dynamically during game execution.
  3. If you need to change this value programmatically, ensure you do so at appropriate times that won’t disrupt ongoing replay playback.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarEnableCheckpoints( TEXT( "demo.EnableCheckpoints" ), 1, TEXT( "Whether or not checkpoints save on the server" ) );
static TAutoConsoleVariable<float> CVarGotoTimeInSeconds( TEXT( "demo.GotoTimeInSeconds" ), -1, TEXT( "For testing only, jump to a particular time" ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardDestroyTearOffActors( TEXT( "demo.FastForwardDestroyTearOffActors" ), 1, TEXT( "If true, the driver will destroy any torn-off actors immediately while fast-forwarding a replay." ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardSkipRepNotifies( TEXT( "demo.FastForwardSkipRepNotifies" ), 1, TEXT( "If true, the driver will optimize fast-forwarding by deferring calls to RepNotify functions until the fast-forward is complete. " ) );
static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarEnableCheckpoints( TEXT( "demo.EnableCheckpoints" ), 1, TEXT( "Whether or not checkpoints save on the server" ) );
static TAutoConsoleVariable<float> CVarGotoTimeInSeconds( TEXT( "demo.GotoTimeInSeconds" ), -1, TEXT( "For testing only, jump to a particular time" ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardDestroyTearOffActors( TEXT( "demo.FastForwardDestroyTearOffActors" ), 1, TEXT( "If true, the driver will destroy any torn-off actors immediately while fast-forwarding a replay." ) );
static TAutoConsoleVariable<int32> CVarDemoFastForwardSkipRepNotifies( TEXT( "demo.FastForwardSkipRepNotifies" ), 1, TEXT( "If true, the driver will optimize fast-forwarding by deferring calls to RepNotify functions until the fast-forward is complete. " ) );
static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );

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

Scope (from outer to inner):

file
function     bool UDemoNetDriver::ShouldClientDestroyTearOffActors

Source code excerpt:

bool UDemoNetDriver::ShouldClientDestroyTearOffActors() const
{
	if (CVarDemoFastForwardDestroyTearOffActors.GetValueOnGameThread() != 0)
	{
		return bIsFastForwarding;
	}

	return false;
}