- Home /
Too subjective and argumentative
Very Confused on Networking HLAPI Practices
Sorry if this is all really newbie but I'm still trying to figure out the new networking system and there still aren't many resources online about it.
Ok so one of the idea's behind the new networking HLAPI is 'the same code should work for both the client and the server', which baffled me at first but I went through the docs and tutorial anyway expecting it'd make sense, but it's still confusing the hell outta me. It's a lot like what I expected, marking certain things as server only, client only, both, (also I assume it's possible to specify only certain clients at a time), but the thing I'm having trouble grasping is that a) the client and server are the same project that will build with the same resources even though each only ever needs certain resources, and b) the HLAPI seems to rely on any game object that need some kind of synchronization being the same exact game object on both client and server.
Another thing about the whole 'same code works for client and server' thing: Throughout the tutorials and docs the only reason the same code works is because you're literally scattering if statements all throughout your code checking if the instance is currently the client or the server and executing different code accordingly. You're still using different code for the client and server, you're just putting them in the same script and surrounding each with if statements. I mean we could've already been doing that before but we don't really because it's just messy and inefficient. How is this an improvement? What am I missing here?
It might make some sense to network like this if the server is a player host, but for a dedicated server, isn't doing it like this just going to be extremely inefficient? Since the client and server are the same project, and also use many of the same objects but only the parts that particular side of the network needs, isn't the excess just going to hog resources for no reason?
For example, the server doesn't need to render any graphics, but because the HLAPI is designed to have the server and client use the same objects, all the server objects will have graphics by default, which I have to specify to turn off individually only for the server for every graphical object in the game.
Another example is the majority of game logic. Normally the client would send input commands to the server and the server would process with game logic and then send the resulting outputs back to the client (and other clients). The client doesn't need any game logic, with perhaps the exception of some prediction. The client only needs code for getting and sending input and receiving and hadnling output. However the SyncVar only works for variables of the exact same script. Which means I can't have a variable on a client script and a variable on a different server script share the same SyncVar. The client or server needs the same gameobject with the same exact scripts including the ones that only the other should ever need. My clients have a bunch of game logic code that they don't need that I have to specify not to use.
I hope this doesn't sound too ranty, I'm expecting I'm just not using the HLAPI properly. How should I be doing completely separate client/server code and still keep things synchronized? Maybe I should only be using command and RPC calls with a middle man and ignore sync vars entirely? I have no idea what the best options are for this.
You need to post this on the forum. Not suitable for UA.
Answer by PsychoDuckArcade · Feb 13, 2016 at 09:25 PM
Another thing, how does TCP vs UDP fit into all this? How do you specify which to use and when?
Follow this Question
Related Questions
How to watch in client applications what it is happening in the server one? 0 Answers
Do i need to have 2 seperate apps communicating for server/client relationship? 2 Answers
"Trying to send command for object without authority" warning but the object is the localPlayer 1 Answer
how to use NetworkServer.SendToClient ? 0 Answers
All players number in Network 1 Answer