I need my game to be framerate independent meaning i want that if i apply a force 10 seconds to an object, the object should always end up at the same location (± a few cm).
As far as i understand, you can enable substepping which makes physics time step fixed.
So i enabled substepping and set max substep delta time to 1/60.
Now, when i call this in the normal tick function of my actor…
MeshComp->GetBodyInstance()->AddForce(FVector(1000000.f, 0, 0), true);
…the actor ends up at the same location only when i set fixed frame rate to 30.
When it’s 60 though, it doesn’t work anymore and the actor always ends up a few meters apart (while also only moving not more than 10 meters, so the difference can get up to like 50%). This might be because my machine only runs the game on 40 fps. But then substepping doesn’t do what it should, i suppose.
Now i wonder if i’m doing something wrong with this add force function, maybe it doesn’t need to be in tick but somewhere else?
Or does substepping in general work differently?
I would be glad for any hints.