Search Unity

[Discussion] Future of fixed step simulation and interpolation

Discussion in 'DOTS Physics' started by Nothke, Jan 23, 2020.

  1. Nothke

    Nothke

    Joined:
    Dec 2, 2012
    Posts:
    112
    I am making a game with Unity Physics but for now the biggest thing that is missing is not running in fixed step and the lack of interpolation.

    Yes, yes, I know you can run the simulation in fixed steps manually, but it is still not "officially" supported. And one of the reasons why you can't just run the simulation in fixed steps is that there is no support for interpolation at the moment. Interpolation is necessary for rendered motion to be smooth and not jittery.

    I have a feeling that an update that is going to introduce it will bring some structural changes so I am a bit unsure if I'll have to rewrite everything to support interpolation or if I should wait first. ... and how long? I don't wish to embark on a project and then have to wait for a year for that to happen.

    So, it would be really nice if some light could be shed on that topic.
     
  2. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    161
    I think netcode already has interpolation and fixed timestep?
     
  3. Nothke

    Nothke

    Joined:
    Dec 2, 2012
    Posts:
    112
    What does netcode have to do anything with [singleplayer] rendering?
     
  4. GliderGuy

    GliderGuy

    Joined:
    Dec 14, 2018
    Posts:
    240
    I'm curious...
    How do you have your presentation abstraction set up? Are you using GameObjects or Entities for it, or do you not have one? As far as GameObjects are concerned, I recommend moving away from them immediately. Through my experience I can tell you that GameObjects should only be used for authoring. If you use them for presentation -- things get really bad fast.

    Assuming you are using Entities for you presentation abstraction, I do not believe you need to fear coding interpolation, at least when it comes to mere positions and rotations. Worst case scenario you can ditch trying to make your own solution and just not interpolate if you feel like you're wasting your time. (That's what I did actually! I plan to take another swing at it sometime... Once Unity Physics is running using a FixedTimeStep that is).

    I do not know of any scheduled update that adds interpolation into the mix of Unity Physics features. Though, I think I remember certain posts from the Unity Team mentioning that interpolation was going to be handled by the developer. Of course, that was a good long while ago, so something may have changed. But that is what I'm assuming at this point.


    I am also curious if Unity has plans to move the Physics Simulation to a FixedTimeStep any time soon. If not, does anybody know how to safely manually update the Physics Simulation using a FixedTimeStep? I manually update all my own systems using a custom system updater, but how are you supposed to do it for one of Unity's prebuilt systems?
     
  5. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    161
    Sorry if I didn't make my intentions clear in the brief post. But I would assume the structural part of how they handle Interpolation and timestep in NetCode in their multiplayer and DotsSample will translate to the _singleplayer_ architecture as well. You can look at the ClientSimulationSystemGroup you can see how ticking simulation is done, and simply copy their interpolation code which is like 3 systems and four components; CurrentSimulatedPosition/PreviousSimulatedPosition + rotation.
     
    Baggers_ and GliderGuy like this.
  6. apaxnid

    apaxnid

    Joined:
    Nov 18, 2012
    Posts:
    27
    Look at ComponentSystemGroup.cs there is functionality to make system groups update in fixed steps, you can make SimulationSystemGroup update in fixed steps
     
    GliderGuy likes this.
  7. GliderGuy

    GliderGuy

    Joined:
    Dec 14, 2018
    Posts:
    240
    Are you implying that Unity updates their own systmes (including physics) in SimulationSystemGroup? Huh, never figured that. I suppose it does make sense, though. The synapses in my brain were probably on break or something (for like the past five months). Anyway, guess I'll just get a reference to that and update it in fixed update! Thanks. :D
     
  8. apaxnid

    apaxnid

    Joined:
    Nov 18, 2012
    Posts:
    27
    No i'm not implying that. https://gametorrahod.com/world-system-groups-update-order-and-the-player-loop/
     
unityunity