I’m trying to wrap my head around the ECS lifecycle. I was under the assumption that (at least some) systems are guaranteed to execute at least once every tick/frame? I thought this was how everything could be deterministic and repeatable. Netcode for entities can use prediction ticks to determine what needs to be resimulated. Player input could be captured per frame for precision on physics simulations.
I was very surprised to see ticks being skipped when adding a Debug.Log to a basic ISystem that logs the current Server Tick (netcode for entities). I realize server tick is different than frames, but I thought a server tick was in lock-step with frames for deterministic and repeatable results.
I’ve read so much documentation and (potentially) outdated code that it’s all starting to blend together. I’d really appreciate some answer to a couple lifecycle questions to help anchor my learning:
Basic:
- Do some systems run at least once per frame?
- Can I get the current frame somehow? (Edit: Found UnityEngine.Time.frameCount)
- If systems don’t run at least once every frame, how can you ensure asynchronous one-time events are only executed once, such as a mouse click for player input? Would you have to maintain state somewhere that you’ve already handled that version of input since you can’t use the execution frame as an indicator of if it has been handled or not?
Appreciate any comments or insights
Edit:
I found that UnityEngine.Time.frameCount seems to consistently increase by 1 each system loop, which is what I was expecting. However, ServerTick on Netcode for Entities increments faster than frame count, therefore some ServerTicks are skipped on system update.
I assume it’s not safe to use frameCount to “timestamp” player input, but I’d like to understand why. Likely due to resimulation/prediction purposes? Such a cool concept but hard to understand