Posted: 21st Sep 2023 18:50
It is a common problem that physics do not have the same behavior at different framerates.
I came here to share a solution that I also use, because it was a problem that took me a long time to solve.
and I'm sure there will be someone else with similar problems


In AppGameKit there are multiple solutions, however all of them will present some disadvantages, especially when there are hundreds of dynamic objects, or hundreds of joints
specifically when there are hundreds of joints, the physics tend to behave very poorly at framerates below 30fps, regardless of whether you use fixed step or not.
and there are other solutions that will add input delay

However, I think this solves all the problems relating to physics and framerate, whether at 10fps or 1000fps.

+ Code Snippet
#CONSTANT RENDER_FRAME_TIME 0.016667

SetSyncRate(0, 1)
lastStepTime as float = 0

// Game Main Loop
Do
  // Physics Control Loop
  inc lastStepTime, GetFrameTime()
  while (lastStepTime >= RENDER_FRAME_TIME)
         Update(RENDER_FRAME_TIME)
      dec lastStepTime, RENDER_FRAME_TIME
  endwhile

  // Game Code
  Input_And_Stuff_And_Logic()

  // Update Tweens, and Render the game and Swap!
  UpdateAllTweens(GetFrameTime())
  Render()
  Swap()
Loop
Posted: 21st Sep 2023 22:23
Instead of calling Update like that, I call StepPhysics with a constant physics frame rate. When it's not a physics tick, I use StepPhysics(0) so that Sync doesn't call StepPhysics internally.
Posted: 22nd Sep 2023 1:36
Yes, I also used a similar method, which was even a script made by you

But recently I noticed some delays on the sprites when moving with other sprites position at the same time, with SetSpritePosition
And this delay was smaller depending on the frame rate
Posted: 27th Oct 2023 19:48
trying this out where i've always let a 30 fps sync rate handle it for my simple games and gotten away with it but shouldn't the last step/update be a fraction of a full RENDER_FRAME_TIME?
+ Code Snippet
  while (lastStepTime >= RENDER_FRAME_TIME)
         Update(RENDER_FRAME_TIME)
      dec lastStepTime, RENDER_FRAME_TIME
  endwhile

otherwise you're pushing a full RENDER_FRAME_TIME before it should (fully) trigger?