Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Is it possible to update an ECS world concurrently without blocking the render loop?

Discussion in 'Graphics for ECS' started by Vuh-Hans, Nov 5, 2018.

  1. Vuh-Hans

    Vuh-Hans

    Joined:
    Sep 24, 2013
    Posts:
    42
    I'm in a situation where I need to separate the game's simulation and it's presentation, and allow the simulation to take as long as it needs on each logical frame without blocking the render loop. The simulation doesn't need physics and doesn't touch the Unity API. The main thread polls the simulation to see if a new logical frame is done, at which point it synchronizes. If the game's graphical framerate is higher than the simulation framerate, the main thread simply skips synchronization for several frames, drawing the previous logical frame multiple times, until the simulation has produced a new logical frame. The end result is that the game's simulation can be slower than the graphics framerate without blocking the rendering loop and has the liberty of varying its rate depending on the computational load to generate the next logical frame.

    My question is if it's possible to do this using ECS and two worlds (one for simulation and one for presentation) and allow the simulation world updates to take however long they need without blocking the Unity render loop. Must an ECS world necessarily synchronize with the update loop every cycle even if it doesn't touch the Unity API outside of the ECS framework itself?