t.OverrideFPS
t.OverrideFPS
#Overview
name: t.OverrideFPS
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This allows to override the frame time measurement with a fixed fps number (game can run faster or slower).\n<=0:off, in frames per second, e.g. 60
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of t.OverrideFPS is to override the frame time measurement with a fixed FPS number, allowing the game to run faster or slower than its normal speed. This variable is primarily used for debugging and testing purposes.
This setting variable is used in the Engine module of Unreal Engine, specifically within the core game loop and time management systems.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime through the console or configuration files.
The associated variable CVarSetOverrideFPS interacts directly with t.OverrideFPS. They share the same value and purpose.
Developers must be aware of several important points when using this variable:
- It’s only available in non-shipping builds (defined within #if !UE_BUILD_SHIPPING).
- It’s marked as a cheat command (ECVF_Cheat), indicating it shouldn’t be used in normal gameplay scenarios.
- The variable expects a float value representing frames per second.
- A value less than or equal to 0 turns off the override.
Best practices when using this variable include:
- Use it only for debugging or testing specific scenarios where controlling the game speed is necessary.
- Remember to disable it (set to 0 or less) when not needed to ensure normal game behavior.
- Be cautious when using in multiplayer scenarios, as it can cause desynchronization.
- Document its usage in testing procedures to ensure consistency across the development team.
Regarding the associated variable CVarSetOverrideFPS:
The purpose of CVarSetOverrideFPS is identical to t.OverrideFPS, as they are essentially the same variable. It’s the C++ representation of the console variable.
This variable is used in the Engine module, specifically in the UEngine::UpdateTimeAndHandleMaxTickRate function, which is part of the core game loop.
The value is set through the console variable system, and it’s read using the GetValueOnGameThread() method.
When the value is greater than or equal to 0.001f, it overrides the normal delta time calculation, effectively controlling the game’s speed.
Developers should be aware that this variable directly affects the game’s timing system and should be used with caution.
Best practices for CVarSetOverrideFPS are the same as those for t.OverrideFPS, with the additional note to be mindful of its impact on the engine’s time management when modifying it programmatically.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:418
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<float> CVarSetOverrideFPS(
TEXT("t.OverrideFPS"),
0.0f,
TEXT("This allows to override the frame time measurement with a fixed fps number (game can run faster or slower).\n")
TEXT("<=0:off, in frames per second, e.g. 60"),
ECVF_Cheat);
#endif // !UE_BUILD_SHIPPING
#Associated Variable and Callsites
This variable is associated with another variable named CVarSetOverrideFPS
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:417
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<float> CVarSetOverrideFPS(
TEXT("t.OverrideFPS"),
0.0f,
TEXT("This allows to override the frame time measurement with a fixed fps number (game can run faster or slower).\n")
TEXT("<=0:off, in frames per second, e.g. 60"),
ECVF_Cheat);
#endif // !UE_BUILD_SHIPPING
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:2757
Scope (from outer to inner):
file
function void UEngine::UpdateTimeAndHandleMaxTickRate
Source code excerpt:
#if !UE_BUILD_SHIPPING
{
float OverrideFPS = CVarSetOverrideFPS.GetValueOnGameThread();
if(OverrideFPS >= 0.001f)
{
// in seconds
FApp::SetDeltaTime(1.0f / OverrideFPS);
LastRealTime = FApp::GetCurrentTime();
FApp::SetCurrentTime(FApp::GetCurrentTime() + FApp::GetDeltaTime());