Download

How to get actual physics delta-time? (with sub-stepping or not)

Hey,
when not using substepping, I assumed that physics delta-time is what I get in the first argument in TickComponent(). Similarly when using sub-stepping in my registered delegate PhysicsSubstepTick(). However it seems I’m wrong in both cases.

I use **PhysX **and I have an OnContact callback, where I get a contact impulse that I convert to force - force = impulse / physics-delta-time.
So for a 100 kg ball, I expect a force to be 980N for normal gravity. And it is, but only when I use physics-time-delta as a hardcoded value which is equal to **max-physics-delta-time **from Project Settings.

If I however use any of the time-deltas I get in TickComponent() or PhysicsSubstepTick(), I get a wrong force. The delta-time I get is larger, and larger than the **max-physics-delta-time **from Project Settings.

A very simple way to reproduce that is to make the Editor window loose focus - force calculated should stay the same. However it goes down to 15N. Physics is then slowed down, so it maintaines the timestep.

So, if **max-physics-delta-time **(or max-substep-delta-time for sub-stepping) is just an upper clamp on the physics timestep, how do I know the actual physics-delta-time of the last update?
And why don’t I get it in PhysicsSubstepTick() then?