UCharacterMovementComponent::GetSimulationTimeStep
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: ENGINE_APIconst
Description
Computes the size of the next movement sub-step given how much time is left in the tick, clamped by MaxSimulationTimeStep and MaxSimulationIterations.
Caveats & Gotchas
- • The final iteration (once Iterations reaches MaxSimulationIterations) always returns the full RemainingTime regardless of MaxSimulationTimeStep, which can produce a step larger than the configured cap on that last pass.
- • If MaxSimulationTimeStep * MaxSimulationIterations is too small for the frame's actual DeltaTime, movement can visibly behave differently than intended at low framerates — this is called out directly in the MaxSimulationTimeStep property comment.
- • Used internally by the physics sub-stepping loop (StartNewPhysics and friends); overriding movement behavior by tuning MaxSimulationTimeStep is preferred over calling this directly.
Signature
float GetSimulationTimeStep(float RemainingTime, int32 Iterations) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| RemainingTime | float | Time remaining in the current tick that still needs to be simulated. | — |
| Iterations | int32 | Current iteration count of the simulation loop, starting at 1. | — |
Return Type
float Example
Sub-stepping loop shape C++
float RemainingTime = DeltaTime;
int32 Iterations = 0;
while (RemainingTime > UE_KINDA_SMALL_NUMBER && Iterations < MaxSimulationIterations)
{
Iterations++;
const float TimeStep = GetSimulationTimeStep(RemainingTime, Iterations);
RemainingTime -= TimeStep;
// ... simulate TimeStep worth of movement ...
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?