How does multiplayer work?

I just wanted to know how multiplayer works, what is needed and how to integrate it into my Game?
Do you need servers or a powerful processing machine?
How to do the ingame chatting?

What your asking is just like asking how does physics work, or AI, or rendering. it is a huge discipline. Depending on how you learn best I’d either pickup a book or start with some YouTube tutorials. Start simple and increase your knowledge little by little. then when your questions are a little less vague the forums can certainly help you out.

Check out the docs here. Multiplayer is a massive undertaking, but Unity has made it much simpler for us with the release of UNet.

Mark a variable with [SyncVar]
Change synced variable inside functions marked [Command]
Server runs that function and the syncvar changes on every instance of that client

That’s all there is to it :smile:

3 Likes

1 Like

3 Likes

Actually a better way to so that will be putting ‘using UnityEngine.Networking’ at top and having a base class of NetworkBehivaour (spell error :P)

That step is implicit for anyone who’s used the system before because you can’t use [Command] on anything other than a NetworkBehaviour :wink:

Protip: I know it’s awkward, but let your clients update the server. It will look like a little lag when things desync instead of rubberbanding. If the server dictates where you are, you rubberband. If you tell the server where you are, it looks like you lagged a little.