Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(7.0) Still confused about how Obi physics updates in 7.0
#3
(07-05-2024, 11:08 AM)josemendez Wrote: What do you mean? all callbacks in Unity are frame rate dependent, since they're called during a specific frame. Framerate independence comes from scaling things by the amount of time passed since last time you did them, regardless of where they are done.

If you mean FixedUpdate vs LateUpdate, a common misconception is that FixedUpdate() is called every X seconds which is not at all the case. It's just that FixedUpdate is guaranteed to be called once per timestep as opposed to once per frame, which means it may be called zero, one, or multiple times per frame while LateUpdate is guaranteed to be called exactly once per frame.

So if 2 seconds have passed since the last frame and your fixed timestep is 0.05, Unity will perform 4 back to back calls to FixedUpdate() during that frame. If 0.01 seconds have passed since the last frame, Unity won't call FixedUpdate that frame and will just accumulate the amount of time passed. You can easily replicate this behavior anywhere, this is pseudocode for what Obi does:

Code:
void LateUpdate()
{
   // accumulate time passed since last frame
   accum += Time.deltaTime;

   // while more than 1 timestep has passed, advance a timestep and subtract it from
   // the accumulator:
   while (accum >= Time.fixedDeltaTime)
   {
       InternalObiUpdate(Time.fixedDeltaTime);
       accum -= Time.fixedDeltaTime;
   }
}

If you're curious about what fixed timestepping means and how it's actually implemented in physics engines, I can recommend this timeless (no pun intended) classic:
https://gafferongames.com/post/fix_your_timestep/



It entirely depends on your script execution order.

kind regards,

Yes, you're 100% correct. I've read the exact article you posted but somehow I totally forgot it when I thought about Obi physics   Lengua

I was getting confused because I set a script's execution order to 10 and it still gets overridden by ObiBone. And it turns out that ObiBone has a default execution order of 100...
Reply


Messages In This Thread
RE: (7.0) Still confused about how Obi physics updates in 7.0 - by kodra - 07-05-2024, 11:32 AM