Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Manually update Physics World and FixedStep catch up (Server Reconciliation)

Discussion in 'Physics for ECS' started by unity-freestyle, Oct 4, 2020.

  1. unity-freestyle

    unity-freestyle

    Joined:
    Aug 26, 2015
    Posts:
    45
    Hello all,

    Suppose there is a Reconciliation World which will be manually updated so entities can playback inputs that were already processed before in the client to catch up with the current input simulation after a server reconciliation message.

    Something like...

    Code (CSharp):
    1. reconciliationEntityManager.CopyEntitiesFrom(EntityManager, entityList.AsArray());
    2.  
    3. SetReconciliationWorldSystemsEnabled(true);
    4.  
    5. for (var updateIndex = 0; updateIndex < length; updateIndex++)
    6. {
    7.      var time = timeBuffer[updateIndex].Value;
    8.  
    9.      reconciliationWorld.SetTime(time);
    10.      reconciliationWorld.Update();
    11. }
    12.  
    13. SetReconciliationWorldSystemsEnabled(false);
    This used to work nicely before the new FixedStepSimulationGroup update. A custom fixed step simulation group already existed with the FixedRateUtils though.

    The problem now is, sometimes it's updating the fixed step group a lot, depending on the last time it was updated before it is manually updated again...

    If I keep sending inputs and reconciliating, should only take few acceptable ms to execute the reconciliation world updates. But if I stop updating for few seconds and try to update again, there is a stall and hundreds of calls to the FixedStep group update.

    From what I've seen from the FixedRateManager code, I believe it's happening because
    m_LastFixedUpdateTime
    is not being overwritten when setting time for the Reconciliation World. However, I didn't find a way to properly do this...

    How should I proceed in this case?

    Many thanks!!!

    === EDIT ===

    Not happening anymore when using the FixedRateSimple in the Reconciliation World.
    Code (CSharp):
    1. FixedRateUtils.EnableFixedRateSimple(reconciliationWorld.GetExistingSystem<FixedStepSimulationSystemGroup>(), reconciliationWorld.Time.fixedDeltaTime);
     
    Last edited: Oct 4, 2020
    bobbaluba, Opeth001 and steveeHavok like this.