I’m mostly designing a single-player game with local multiplayer, but I know that if I ever want to extend it online I’ll have to incorporate some networking from the very beginning or suffer writing the whole thing over again. I’ve gone through some tutorials and I’m starting to understand the structure.
I’m using a WoW-clone sort of input and control architecture, with a movement vector, camera rotation, and various action bars.
I think I know how I want to handle my player system for easy plugging-in to characters they’re controlling. I’ll have a big list (or maybe a Dictionary referenced by player ID) of player objects (in-turn with references to the player ID) which can be referenced for plugging in, and these player objects will also keep data about player input.
Does this sound like a good setup?
What confuses me though is the case of authoritative servers. I understand that NetworkViews can have the player control a character on their own end, and RPCs would be useful for things like more hefty functions. But how would I go about keeping track of player input on the client side, and keeping the Player Object on the server constantly updated?
I’d forgotten the first tutorial I watched was outside of Unity so they had their own function for sending data.
Would I use RPCs to send various player inputs, or is there a more efficient function?
I will have up to 4 players on a single connection, which means I would have to send four movement vectors, camera positions and rotations, and multiple actions at any given moment.
the default unity tutorials they just look at the position and send it. now sending input could be one thing but i think the result might vary depending how it goes anyhow. rpc are ok in some faction such as things like instantiating spells and so on. now if you are going to send something like almost every frame don’t use rpc because you might reduce your bandwidth. instead look at. OnSerializeNetworkView function. that is why it was made. in case you didn’t knew if your network view is set to reliable that means only if the object changed the message will be sent. in unreliable pretty much sends it all the time. now how is this good? for example a player that is just standing still they don’t need to send info to us since they arepretty much afk maybe and so on, eigther way it’s a simple explanation. so for now just leave at default reliable and then you can experiment with it.
Ah, so if my Player class is a MonoBehaviour object with a NetworkView on and observing it, it will automatically transfer my Player’s variables to the server object?
Player’s movement vector is set by input → Player’s NetworkView updates the server’s version of the Player object → Server’s character reads Player’s input and moves accordingly?