Hello,
I know this is a topic that has been brought up numerous times. I have spent the last 6 or so hours googling, and I’ve looked at every thread in the forum, every question/answer in the Answers section, and I haven’t found anything that can help me get started. I’ve found some useful bits of very general information, like lockstep etc, but Im not sure where to actually start.
Here are my goals and requirements:
-
A competitive, eSport-caliber game with extremely low latency, possible regionally limited to ensure good connections.
-
A small-scale, tactical 1v1 game with at MOST 30-40 units per player (though typically around 6-10 units).
-
Authoritative server is not an option. I can’t accept the latency hit that results from it, nor can I afford it or scale it. It HAS to be peer-to-peer. I will have a server included at some point, just to check for disconnects and possibly to check for cheaters trying to edit game vars like unit costs and build times, but that’s all it will do.
-
Ideally it will be true peer-to-peer and fully distributed, so that if I do support 2v2, the “host” doesn’t kill the game if they leave - it just keeps running.
-
I am ok with everyone slowing down to the speed of the slowest connection. Eventually I will have a matchmaking server that prioritizes good connections, so it will mitigate that problem.
-
I will not be doing any rigidbody physics simulations in the game at all. It will all be procedural, with various prefab animations and explicit transform-to-transform targeting. Though I don’t know if things like sphere colliders and Raycasts count as physics (e.g. use imprecise floating point math).
-
I don’t plan on implementing replays right away. Replays are useful but streaming and commentary has taken over as the primary means to watch a match, so replay functionality isn’t a huge requirement. Thus I don’t technically need a fully deterministic simulation. My goal is just to get a playable game, and if it works, I’m fully willing to re-code it from scratch to support replays, if necessary.
What I don’t know is where to start. Is it possible to do deterministic lockstep in Unity, in case I wanted to? Can I make it semi-deterministic? If that’s not possible, given my very small unit counts, is it possible to just send full game state data between clients every 100ms or so to always ensure they’re fully synced? Can someone give me an example of how I would separate simulation logic frame rate from visual frame rate? How do I count “ticks” and keep them in sync between players?
I’ve searched high and low and I just can’t find a tutorial that sets the foundation for this type of networking in Unity.
Any help would be MUCH appreciated.