Replies: 2 comments 4 replies
-
Yes the wheels/gear/spring sim can become unstable at lower simulation frequencies. JSBSim is recommended to run at 120hz. And it's also recommended to run a constant delta, not to use use a variable rate #449 (comment). I wrote a little ugly code to run the Unreal Engine Plugin at a constant 120hz, independent of game rate. It works great at any game rate, even wildly fluctuating rates. The code below is run on each game tick/frame. Feel free to use it: //calculate sim rate to be 120hz independent of game tick rate(Pseudo fixed rate, dev/user needs to set game to a fixed rate too)
simDtime = 120.f/(1.f / DeltaTime); // DeltaTime is Unreal Engine's each current frame delta time.
remainder = remainder + fmodf(simDtime,1);
simloops = truncf(simDtime) + truncf(remainder);
remainder = fmodf(remainder,1);
//jsbsim recommends to step sim at 120hz, eg 1/120 = 0.0083..
Exec->Setdt(0.008333333333333333);
//Send Commands and State to JSBSim
CopyToJSBSim();
//step sim x times per game tick
for (int i = 0; i < simloops; i++)
{
Exec->Run();
}
//Get the results from JSBSim
CopyFromJSBSim(); |
Beta Was this translation helpful? Give feedback.
-
Or what I typically do is browse to the relevant section of the code on Github, and then left-click on the starting line and then shift-left-click on the last line which then highlights the section of code, and then select the "Copy permalink" option from the context menu. |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm developing a game. Recently I made one major change. I set delta t on each step of simulation to value = time between to frames. Sometimes, when fps drops(delta t grows), the plane start jump on direct surface. Can floating delta t cause this? Is it valid to set delta t this way?
Beta Was this translation helpful? Give feedback.
All reactions