Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How does multiplayer work?

Discussion in 'General Discussion' started by blastintyres, Aug 5, 2015.

  1. blastintyres

    blastintyres

    Joined:
    Nov 19, 2014
    Posts:
    79
    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?
     
  2. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    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.
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Check out the docs here. Multiplayer is a massive undertaking, but Unity has made it much simpler for us with the release of UNet.
     
  4. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    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 :D
     
    Ony, Dreamaster and Kiwasi like this.
  5. blastintyres

    blastintyres

    Joined:
    Nov 19, 2014
    Posts:
    79
     
    Ony likes this.
  6. ostrich160

    ostrich160

    Joined:
    Feb 28, 2012
    Posts:
    679
     
    SunnyChow, Tomnnn and Ony like this.
  7. Yash987654321

    Yash987654321

    Joined:
    Oct 22, 2014
    Posts:
    729
    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)
     
  8. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    That step is implicit for anyone who's used the system before because you can't use [Command] on anything other than a NetworkBehaviour ;)

    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.