Search Unity

a few questions about unity physics and dots

Discussion in 'Entity Component System' started by spirachi77, Nov 18, 2020.

  1. spirachi77

    spirachi77

    Joined:
    Sep 26, 2017
    Posts:
    17
    Hi!
    I'm trying to make a fighting game using unity DOTS and Physics, I have done some digging and I got a few questions,

    I need to decouple rendering and physics updates, how would I do this?
    Could I use the hybrid renderer for this, if so, then how?
    If not, then how could I decouple rendering and physics steps?
    Does anyone have any code examples of controlling when the physics steps?
    Where would I copy the physics world data from and where should I store it?

    Thank you!
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    991
    Last edited: Nov 19, 2020
    spirachi77 likes this.
  3. spirachi77

    spirachi77

    Joined:
    Sep 26, 2017
    Posts:
    17
    Gotcha! This is helpful, thanks!

    One quick question though, how would I handle rolling back the physics world and re-simulating it? Would I need to manually rollback and re-step the simulation? If, so, then how?
     
  4. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    991
    This goes beyond my own testing on hte subject but I think you should keep a copy of the physics world from a server tick (probably a new system after the buildphyisicsworls system). Then to roll back it you would nee to replace the physics world build by the Unity system with the one from you copy and tick the simulation as many time as needded to catchup with the current server tick.

    You may also need a similar copy of all the inputs that affects the simulation to play them back along teh resimulation.
     
  5. spirachi77

    spirachi77

    Joined:
    Sep 26, 2017
    Posts:
    17
    Can I just let the physics world tick on its own or should I control when the tick occurs through a monobehavior or something?
     
  6. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    991
    Depend on your use case, if it's just a replay, you can let it tick itself I think, but in case of a networked game, you probbly don't want your simulation to be at tick 50 and roll back physics at tick 45 and let it be. Otherwise, At simulation tick 51 you'd be at physics tick 46. So I think you should probably ficd a way to tick the physics system group 5 times after the rall back to tick 45 to catch up to tick 50.

    Again as a reminder, I did not do any of this ever, I'm just think 'out loud' what I would try to do in your situation.

    If anyone else has a better understanding of those things, feel free to jump in ;).

    Also you might want to consider making a dedicated post in the https://forum.unity.com/forums/dots-physics.422/ sub forum.