demo.TimeDilation
demo.TimeDilation
#Overview
name: demo.TimeDilation
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Override time dilation during demo playback (-1 = don\'t override)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.TimeDilation is to override the time dilation during demo playback in Unreal Engine 5. This setting variable is primarily used for the demo recording and playback system.
-
The Unreal Engine subsystem that relies on this setting variable is the Demo Net Driver, which is part of the engine’s networking and replay system.
-
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.0f, which means “don’t override” by default.
-
This variable interacts with the World’s WorldSettings object, specifically the DemoPlayTimeDilation property. When the value of demo.TimeDilation is 0.0 or greater, it overrides the DemoPlayTimeDilation of the World’s settings.
-
Developers must be aware that this variable affects the playback speed of demo recordings. A value of 1.0 would play the demo at normal speed, values less than 1.0 would slow it down, and values greater than 1.0 would speed it up.
-
Best practices when using this variable include:
- Use it for debugging or testing purposes, such as slowing down a demo to examine specific events.
- Be cautious when changing this value during runtime, as it can affect gameplay and physics simulations.
- Remember to reset it to -1.0 (or remove the override) when normal playback is desired.
Regarding the associated variable CVarDemoTimeDilation:
The purpose of CVarDemoTimeDilation is the same as demo.TimeDilation, as they are essentially the same variable. CVarDemoTimeDilation is the C++ representation of the console variable.
-
It’s used within the Demo Net Driver subsystem of Unreal Engine.
-
The value is set when the engine initializes its console variables, with a default of -1.0f.
-
It directly interacts with the World’s WorldSettings object, setting the DemoPlayTimeDilation when its value is 0.0 or greater.
-
Developers should be aware that this variable is checked every tick of the Demo Net Driver, allowing for real-time adjustments to demo playback speed.
-
Best practices include:
- Accessing this variable through the console or game code when you need to dynamically change demo playback speed.
- Using it in conjunction with other demo-related variables for comprehensive control over demo playback.
- Resetting it to -1.0f when you want to revert to the default demo playback behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:47
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarDemoRecordHz( TEXT( "demo.RecordHz" ), 8, TEXT( "Maximum number of demo frames recorded per second" ) );
TAutoConsoleVariable<float> CVarDemoMinRecordHz(TEXT("demo.MinRecordHz"), 0, TEXT("Minimum number of demo frames recorded per second (use with care)"));
static TAutoConsoleVariable<float> CVarDemoTimeDilation( TEXT( "demo.TimeDilation" ), -1.0f, TEXT( "Override time dilation during demo playback (-1 = don't override)" ) );
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." ) );
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoTimeDilation
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:47
Scope: file
Source code excerpt:
TAutoConsoleVariable<float> CVarDemoRecordHz( TEXT( "demo.RecordHz" ), 8, TEXT( "Maximum number of demo frames recorded per second" ) );
TAutoConsoleVariable<float> CVarDemoMinRecordHz(TEXT("demo.MinRecordHz"), 0, TEXT("Minimum number of demo frames recorded per second (use with care)"));
static TAutoConsoleVariable<float> CVarDemoTimeDilation( TEXT( "demo.TimeDilation" ), -1.0f, TEXT( "Override time dilation during demo playback (-1 = don't override)" ) );
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." ) );
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1457
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDispatch
Source code excerpt:
}
if (CVarDemoTimeDilation.GetValueOnGameThread() >= 0.0f)
{
World->GetWorldSettings()->DemoPlayTimeDilation = CVarDemoTimeDilation.GetValueOnGameThread();
}
// DeltaSeconds that is padded in, is unclampped and not time dilated
DeltaSeconds = FReplayHelper::GetClampedDeltaSeconds( World, DeltaSeconds );
// Update time dilation on spectator pawn to compensate for any demo dilation