Mikemikenmike / effective-adventure

1 stars 0 forks source link

Single and Multiplayer Architecture #1

Open Mikemikenmike opened 6 years ago

Mikemikenmike commented 6 years ago

I brought this up in Discord but figured we may want to use github for documentation purposes.

I'm proposing the Client-Server architecture. I think it's important for players to have the option to play their server without the original host if they choose. This also enables the game to be run remotely on bigger and badder machines. I don't think any of you guys have an issue with this.

What I really wanted to talk about using this architecture even in single player mode. That is, the steps to create/load/join a game are identical for Single Player games as they are for Multiplayer game. The differentiating factor would be the server configuration; Single player servers whitelist only the player that created them.

@Praxian brought up a good point:

on the multiplayer thing, if someone selects a single player game, do they need to go through the process of setting up a server that no one can join?

It's clear that this approach only really works if the server setup is reasonably transparent to the player. I think that possible.

JakeNeighbors commented 6 years ago

I would recommend the following:

  1. Write the server in C# so the server can be both installed as part of the game and also compiled as a stand alone server executable.
  2. Server should be packaged with the game and used in both single player and multiplayer to provide consistent operations.
  3. When playing single player, the client opens a server in an application process and binds the server to loopback (127.0.0.1)
  4. If possible, I would highly recommend using WebSockets as the protocol over TCP or UDP as it provides nearly identical performance as TCP, but with more features (protocol negotiation, chunking data automatically in messages as part of the protocol, SSL specifications)
Mikemikenmike commented 6 years ago

As far as I can tell most of those points are abstracted away by Unity's NetworkManager/HLAPI (High Level API) as a whole. The LLAPI is definitely a layer on a UDP socket which leads me to believe HLAPI is as well.

Unity allows an instance of the game to be a Client, Server, or Host (Client and Server). Host is almost what we want, except that the communication between the local client and server isn't done the same as remote clients to the server. This is probably why it's difficult to create dedicated servers for games like Dead by Daylight.

Praxian commented 6 years ago

Just a note, Dead by Daylight was made with with Unreal.
Also you guys are going to need to explain a lot of these things to me haha.