demo.GotoTimeInSeconds
demo.GotoTimeInSeconds
#Overview
name: demo.GotoTimeInSeconds
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
For testing only, jump to a particular time
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.GotoTimeInSeconds is to allow developers to jump to a specific time in a network replay for testing purposes. This variable is part of Unreal Engine’s demo playback system, which is used for recording and replaying gameplay sessions.
This setting variable is primarily used in the Engine module, specifically within the DemoNetDriver subsystem. The DemoNetDriver is responsible for handling network replay functionality in Unreal Engine.
The value of this variable is set through the console or configuration files. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime through console commands.
The associated variable CVarGotoTimeInSeconds directly interacts with demo.GotoTimeInSeconds. They share the same value and purpose.
Developers must be aware of the following when using this variable:
- It’s intended for testing purposes only and should not be used in production builds.
- The variable is checked during the TickDemoPlayback function of the UDemoNetDriver class.
- Once used, the variable is automatically reset to -1 to prevent unintended repeated jumps.
Best practices when using this variable include:
- Use it only during development and testing phases.
- Ensure it’s set to -1 (or remove it entirely) in production builds to avoid unexpected behavior.
- Be cautious when using it in conjunction with other demo playback features, as it may interfere with normal playback flow.
Regarding the associated variable CVarGotoTimeInSeconds:
The purpose of CVarGotoTimeInSeconds is identical to demo.GotoTimeInSeconds. It’s a console variable that allows developers to specify a time in seconds to jump to in a demo playback.
This variable is used in the Engine module, specifically within the DemoNetDriver subsystem.
The value of CVarGotoTimeInSeconds is set through console commands or configuration files. It’s defined as a static TAutoConsoleVariable
CVarGotoTimeInSeconds directly interacts with the demo.GotoTimeInSeconds setting. When CVarGotoTimeInSeconds is set to a value >= 0, the DemoNetDriver will call the GotoTimeInSeconds function with this value and then reset CVarGotoTimeInSeconds to -1.
Developers should be aware that:
- This variable is checked every tick during demo playback.
- It’s automatically reset to -1 after use to prevent continuous jumping.
Best practices for using CVarGotoTimeInSeconds include:
- Use it only for debugging and testing purposes.
- Ensure it’s not accidentally left set in production builds.
- Be mindful of potential interactions with other demo playback systems when using this variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:50
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDemoSkipTime( TEXT( "demo.SkipTime" ), 0, TEXT( "Skip fixed amount of network replay time (in seconds)" ) );
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( "" ) );
#Associated Variable and Callsites
This variable is associated with another variable named CVarGotoTimeInSeconds
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:50
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDemoSkipTime( TEXT( "demo.SkipTime" ), 0, TEXT( "Skip fixed amount of network replay time (in seconds)" ) );
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( "" ) );
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2798
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoPlayback
Source code excerpt:
}
if (CVarGotoTimeInSeconds.GetValueOnGameThread() >= 0.0f)
{
GotoTimeInSeconds(CVarGotoTimeInSeconds.GetValueOnGameThread());
CVarGotoTimeInSeconds.AsVariable()->Set(TEXT( "-1" ), ECVF_SetByConsole);
}
if (FMath::Abs(CVarDemoSkipTime.GetValueOnGameThread()) > 0.0f)
{
// Just overwrite existing value, cvar wins in this case
GotoTimeInSeconds(GetDemoCurrentTime() + CVarDemoSkipTime.GetValueOnGameThread());