Well, the answer might be obvious, but I am a bit confused about this.
If my multiplayer game will be hosted by players (so not dedicated server, just to clarify), do I need to for example draw graphics (like HUD) on the server, or the Player who hosts the game will act as a client, but also running as a server in the background somehow?
I mentioned the HUD as an example because typically it’s fine to only run it on client.
Based on my experience when I tried to test it in the editor I would answer “yes, I need to draw graphics on server as well”, but I want to be sure.
There is also that bug of listen server drawing all the huds from clients, well maybe i am doing something wrong, but cannot find solution for listen server to not spawn all huds that clients are spawning.
On top of that you need to replicate some code (and add checks) for listen server, because it is hybrid between server and client. Stuff gets unnecessary messy with code. It is almost like i am developing additional client fork that is listen server. That was second reason for dropping whole listen server idea (at least for now).
And last thing that i am unsure (I didn’t check it yet). But I think dedicated server runs on separate thread than clients, it also does not load all that graphiscs stuff. Nowadays all CPU are multicore, so dedicated server will improve FPS on hosting PC, it will unload all game calculations to separate core (if there is enough of ram for both instances). This hardware side of things needs either explanation from Epic or some testing, but I am assuming that Epic engineers are not dumb and they did what I am thinking they should do.
I’m not sure what you mean, what I did to achieve the HUD (I’m talking about Widgets here that act as a Heads Up Display, not the HUD class) only showing on the client was to put a Switch Has Authority node before creating the widget and adding it to the client’s screen using the ‘Remote’ output pin from the Swith Has Authority node. This way when I launch the game in the editor the window that says server does not have that widget but the clients have. This led me to the conclusion that in case of a player hosted game you also need to add the Widget to the server, unless you want the host to play without a HUD.
Yes has authority solves hud for clients. But try to run LISTEN SERVER, make sure hud is different on each client. You will see all clients huds all together on listen server screen. At least i have that problem, you will not notice it if all clients have exactly same hud rendered, easy way is to add text widget and display random number in it, i see all the numbers on server hud.
And yes you are guessing correctly. For player hosted game (ie listen server) you need to add hud on server, then you need to process that client (server) input on server side, and everything else that should be client only need to be done on listen server. You basically need to make virtual client for listen server. There probably is some clean way to make it, but to get there i need to have more multiplayer coding practice. I will try to make some switch (like authority one) that checks if this is fake listen server client or not.
But multiple huds rendered for listen server are show stopping for it. And as i suspect in last paragraph listen server do not improve fps for server anymore. Instead i would add code that profiles all connected PCs and picks most powerful for server, or at least suggest it to players in lobby.