MaxSubstepDeltaTime
MaxSubstepDeltaTime
#Overview
name: MaxSubstepDeltaTime
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MaxSubstepDeltaTime is to control the maximum time step used in physics simulations within Unreal Engine 5. It is primarily used for the physics system to ensure stability and accuracy in simulations, especially when dealing with fast-moving objects or complex interactions.
This setting variable is utilized by the physics subsystem of Unreal Engine, particularly in the AnimGraphRuntime module and the core Engine module. It’s also used in the AnimDynamics system, which is part of the animation framework.
The value of MaxSubstepDeltaTime is typically set in the UPhysicsSettings class, which is part of the Engine’s configuration system. It can be modified through the project settings in the Unreal Editor or programmatically.
MaxSubstepDeltaTime interacts closely with other physics-related variables such as MaxSubsteps, MaxPhysicsDeltaTime, and bSubstepping. These variables work together to control the physics simulation’s behavior and performance.
Developers must be aware that this variable directly affects the trade-off between simulation accuracy and performance. A smaller MaxSubstepDeltaTime value can lead to more accurate simulations but at the cost of increased computational load.
Best practices when using this variable include:
- Balancing it with MaxSubsteps to achieve the desired simulation quality without overly impacting performance.
- Adjusting it based on the specific needs of your game or application, considering factors like the speed of moving objects and the complexity of physics interactions.
- Testing thoroughly with different values to find the optimal setting for your specific use case.
- Being cautious when modifying it, as it can significantly affect the behavior of physics simulations in your game.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:342, section: [/Script/Engine.PhysicsSettings]
- INI Section:
/Script/Engine.PhysicsSettings
- Raw value:
0.016667
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_AnimDynamics.cpp:375
Scope (from outer to inner):
file
function void FAnimNode_AnimDynamics::EvaluateSkeletalControl_AnyThread
Source code excerpt:
{
float CurrentTimeDilation = Output.AnimInstanceProxy->GetTimeDilation();
float FixedTimeStep = MaxSubstepDeltaTime * CurrentTimeDilation;
// Clamp the fixed timestep down to max physics tick time.
// at high speeds the simulation will not converge as the delta time is too high, this will
// help to keep constraints together at a cost of physical accuracy
FixedTimeStep = FMath::Clamp(FixedTimeStep, 0.0f, MaxPhysicsDeltaTime);
#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_AnimDynamics.cpp:813
Scope (from outer to inner):
file
function void FAnimNode_AnimDynamics::InitPhysics
Source code excerpt:
AnimPhysicsMinDeltaTime = Settings->AnimPhysicsMinDeltaTime;
MaxPhysicsDeltaTime = Settings->MaxPhysicsDeltaTime;
MaxSubstepDeltaTime = Settings->MaxSubstepDeltaTime;
MaxSubsteps = Settings->MaxSubsteps;
}
else
{
AnimPhysicsMinDeltaTime = 0.f;
MaxPhysicsDeltaTime = (1.0f / 30.0f);
MaxSubstepDeltaTime = (1.0f / 60.0f);
MaxSubsteps = 4;
}
SimSpaceGravityDirection = TransformWorldVectorToSimSpace(Output, FVector(0.0f, 0.0f, -1.0f));
}
break;
#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_AnimDynamics.h:547
Scope: file
Source code excerpt:
float AnimPhysicsMinDeltaTime;
float MaxPhysicsDeltaTime;
float MaxSubstepDeltaTime;
int32 MaxSubsteps;
//////////////////////////////////////////////////////////////////////////
// Active body list
TArray<FAnimPhysLinkedBody> Bodies;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/PhysicsSettings.h:221
Scope (from outer to inner):
file
class class UPhysicsSettings : public UPhysicsSettingsCore
Source code excerpt:
/** Max delta time (in seconds) for an individual simulation substep. */
UPROPERTY(config, EditAnywhere, meta = (ClampMin = "0.0013", UIMin = "0.0013", ClampMax = "1.0", UIMax = "1.0", editcondition = "bSubStepping"), Category=Framerate)
float MaxSubstepDeltaTime;
/** Max number of substeps for physics simulation. */
UPROPERTY(config, EditAnywhere, meta = (ClampMin = "1", UIMin = "1", ClampMax = "16", UIMax = "16", editcondition = "bSubstepping"), Category=Framerate)
int32 MaxSubsteps;
/** Physics delta time smoothing factor for sync scene. */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysLevel.cpp:147
Scope (from outer to inner):
file
function void UWorld::SetupPhysicsTickFunctions
Source code excerpt:
static const auto CVar_MaxPhysicsDeltaTime = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("p.MaxPhysicsDeltaTime"));
PhysScene->SetUpForFrame(&DefaultGravity, DeltaSeconds, UPhysicsSettings::Get()->MinPhysicsDeltaTime, UPhysicsSettings::Get()->MaxPhysicsDeltaTime,
UPhysicsSettings::Get()->MaxSubstepDeltaTime, UPhysicsSettings::Get()->MaxSubsteps, UPhysicsSettings::Get()->bSubstepping);
}
void UWorld::StartPhysicsSim()
{
FPhysScene* PhysScene = GetPhysicsScene();
if (PhysScene == NULL)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysSubstepTasks.cpp:214
Scope (from outer to inner):
file
function float FPhysSubstepTask::UpdateTime
Source code excerpt:
UPhysicsSettings * PhysSetting = UPhysicsSettings::Get();
FrameRate = PhysSetting->MaxSubstepDeltaTime;
MaxSubSteps = PhysSetting->MaxSubsteps;
float FrameRateInv = 1.f / FrameRate;
//Figure out how big dt to make for desired framerate
DeltaSeconds = FMath::Min(UseDelta, MaxSubSteps * FrameRate);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicsSettings.cpp:23
Scope (from outer to inner):
file
function UPhysicsSettings::UPhysicsSettings
Source code excerpt:
, bTickPhysicsAsync(false)
, AsyncFixedTimeStepSize(1.f / 30.f)
, MaxSubstepDeltaTime(1.f / 60.f)
, MaxSubsteps(6)
, SyncSceneSmoothingFactor(0.0f)
, InitialAverageFrameRate(1.f / 60.f)
, PhysXTreeRebuildRate(10)
, MinDeltaVelocityForHitEvents(0.f)
{