I'm implementing a threaded engine.. but thinking about how I would handle input when its networked.
At the moment its not networked and it goes like this(n is frame number):
n=0: Platform input is read at start of frame. Input system handles the input and sends the results off to the physics system
n=1: Physics system would calculate the new positions
n=2: Render system renders the new position.
Would this be acceptable?
I could make the render system dependent on the physics system and the render system dependent on the input system so the tasks of each system would all run on the same frame, but then if the other threads on my engine are really fast I would defeat the purpose of doing it multi threaded anyways. Whats more realistic would be to make the physics system dependent on the input system so I would reduce it to just one frame lag.
What I'm thinking for a networked game:
n=0: Platform input is read. Then its sent to the server. On the server its also checks if there's incoming input before it starts running any of the threaded tasks. Input system handles the input and sends the results off to the physics system
n=1: Physics system on the server would calculate the new positions.
n=2: Network system on server sends the new positions to clients. Network system on the clients receives the new positions
n=3: Render system renders the new position
There could also be network lag on frame 0 and 2 here so the input lag would be variable. Is this acceptable or do I need some kind of synchronization?
Now with this I could do some of the same dependency tricks to reduce it. I could get the physics update into n=0 and maybe even make the render system dependent on the network system so it is run before the rendering task can start. Reducing it to either;
n=0: input
n=2: render
or;
n0: input
n=1: render
+ the network lag of course..
I guess I want as little lag as possible, but since I will reduce concurrency with this whats acceptable?
Got a lot of answers just by writing this post, but still need some more opinions on this.. Hopefully its readable and clear enough






