Search Unity

Predictive Physics in Entities 0.5 early next year?

Discussion in 'NetCode for ECS' started by Occuros, Dec 21, 2021.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Greetings,

    We have heard a little about what is coming for the entities package in general in 0.5 early next year, and I was wondering if predictive physics will also be part of the update of netcode?

    Any information would be greatly appreciated.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    Short answer: 0.5 will include predictive physics support.
    Longer story (but still short):
    When predicted physics is enabled, In 0.5 all the physics systems will run inside the prediction loop (more details in the 0.5 docs) instead of the FixedUpdateSytemGroup.
    There are some performance implication and limitation that is better to keep in mind: physics based effect, particles or any other "non gameplay" related physics, are also executed there.
    Because the physics run in the prediction loop, it is executed multiple time per frame; that is fine for ghosts but not for others. There are ways to alleviate that, but requires some custom user code.

    For 1.0, we are going to change that already, by adding support for multiple physics world (one replicated, one client only) and will make it possible to split the physics handling as necessary.

    Need to mention though that it may be possible to achieve something similar also in 0,5, but would requires some changes by the user.
     
  3. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Thank you @CMarastoni, that is some very exciting news! Wish we could already get our hands on that release and experiment.

    How likely is it that a networked stacking of cubes would be possible with the new predictive physics working with netcode (like a physics-based Jenga game)?
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    Stacking by itself is a different problem set by its own, but Unity.Physics contacts generation should be stable enough to simulate a Jenga stack, in general.
    With predicted physics you can definitively simulate the game on both client and server, so client side feel responsive and the simulation convincing. Unity.Physics is deterministic on the same platform, but not 100% across platforms, that should kept in mind. However, because the server state is authoritative, the simulation should still converge to a state that is very very close the server one. 100% determinism is not required only because we are still using state replication and states received quite often (60/30 per sec).
    Because the client is always ahead of the server (so it predict the game state quite ahead, based on the latency), the inherent instability of stacks, and latency jitter, I'm expecting some some custom logic will be necessary but I think you can make it work.
    It also depend on how the game flow is. If the player can modify the stack in turn then things are easier. If player can modify the stack "together", it can get really tricker (if not really really hard).
     
    Dan-Foster and Occuros like this.