Physics Sub-Stepping

Could you post a more extensive example?

Hi I have a question: Do you think it is possible, to substepping physic with a constant delta time, and at the end interpolate the left over time? (just used in this frame, discard it and recalculate in next update).

How do you enable substepping and tie it to an update now? This no longer works, the BodyInstance->GetPxRigidBody(); is always nullptr and the bound function CustomPhysics() is never called. Yeah, substepping is enabled in project settings -> physics.

Epic please document this properly.

Enable Physic Simulation for body component. CustomPhysics should be called. For Actor, better use this function for Actors::Tick, we had some artifacts using it in Component.

Can I enable and disable sub-stepping dynamicly? I have throwing logic where enemy can throw FPP Character on ragdoll and everything looks fine if there is no frame drop. I want to use sub-stepping only when this situation occure, not on default because i want to save CPU usage on other stuff.

I made a tutorial here about making a fixed timestep, that might be the thing you people are missing :slight_smile:

1 Like

Hey is there any chance you could send me those files? Thank you!

@anonymous_user_d573ef49 sry to revive an old thread but does this still work in UE 5.1? With the switch to the Chaos physics engine, it seems that @anonymous_user_eebd5ec2 's example of interacting with the SubStep Tick is no longer possible. Is there an alternative?

Or does Chaos somehow make it that this functionality (custom Tick) is no longer needed?

You can use Async Physics Tick, in which there is an additional node in actor bps for using the fixed timestep

Using UE 5.1 - I managed to hook on to the c++ physics substeps using various guides online, but nothing gave me substeps. It calls my physics substep in sync with tick.
Is this functionality defuct? For my spaceship, i either have to live with exploding physics or slow motion on low framerate. Neither seems reasonalble.

My setup:

UPhysicsSettings::Get()->bSubstepping = true;
    OnCalculateCustomPhysics.BindUObject(this, &USpaceship::PhysStep);
}

Tick:

UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(Owner->GetRootComponent());
    PrimitiveComponent->GetBodyInstance()->AddCustomPhysics(OnCalculateCustomPhysics);
 UE_LOG(LogTemp, Warning, TEXT("TickComponent %f"), DeltaTime);

PhysStep:

void USpaceship::PhysStep(float DeltaTime, FBodyInstance* BodyInstance)
{
    UE_LOG(LogTemp, Warning, TEXT("PhysStep %f"), DeltaTime);
}

The output when console t.maxFPS 60

LogTemp: Warning: PhysStep 0.023294
LogTemp: Warning: TickComponent 0.023294
LogTemp: Warning: PhysStep 0.026082
LogTemp: Warning: TickComponent 0.026082

Output when t.maxFPS 30

LogTemp: Warning: TickComponent 0.033334
LogTemp: Warning: PhysStep 0.033334
LogTemp: Warning: TickComponent 0.033334
LogTemp: Warning: PhysStep 0.033358

My maximum step size is set to 1/60 and i would expect several PhysTicks pr frame. Am i misunderstanding something?

I have of course been in the settings and tried all combinations of stepsizes anbd options I could think of.

Just a note, i got it to work using a plugin this generous guy provided here:

After a little tweaking I got fixed size async physics stepping and my spaceship does not explode any more.

The physics simulation is then ticked multiple times per frame. The number of sub-steps taken will depend on how small your max sub-step delta time is set to.