Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to properly do networking

Discussion in 'Multiplayer' started by mrgohut, Sep 25, 2017.

  1. mrgohut

    mrgohut

    Joined:
    Feb 8, 2014
    Posts:
    134
    I'm a little bit confused about the way that i should write my multiplayer.
    Should i use RPC, Command etc.. or Transport Layer (basically everything from scratch)?
    For what i understand the first thing is HLAPI and the second is LLAPI, right?

    I want to have separately server build and client build.
     
  2. cyunide

    cyunide

    Joined:
    Sep 20, 2017
    Posts:
    9
  3. mrgohut

    mrgohut

    Joined:
    Feb 8, 2014
    Posts:
    134
    Hmm okay, but for what I can see all the scripts are on one build which can be Client Or Server and i want to make separate scripts on server and client builds (it's safer, right?) so the point is - can i do that with this RPCs, Commands etc..
     
  4. cyunide

    cyunide

    Joined:
    Sep 20, 2017
    Posts:
    9
    Sure you can. When you do that example, you will have an option through the NetworkHUD to run it as server only. If you wanted them as seperate exes for example, you would just do 2 builds but you wouldn't have to have 2 separate projects. it fully supports [Command] etc.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The UNET HLAPI is built around the idea that both client and server are running the same scene with the same scripts. When you update a syncvar on the server, it updates the same syncvar in the same script on the client. When you call a command on the client it runs the same command on the same script on the server. If you want to include a different set of scripts on the client and server while using the built in networking, you're probably going to have to build your own high level system on top of UNET's network messages and stick to using NetworkServerSimple.
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm fairly certain all the scripts in your project will end up in both builds.
     
  7. cyunide

    cyunide

    Joined:
    Sep 20, 2017
    Posts:
    9
    This is true, and there would be some enabling / disabling you would need to do before clicking build. I was only meaning that in the development stage you would have everything in one place to make things easier. Upon final build, you can disable / enable any scripts you wish. If you REALLY wanted to, another option is to duplicate the project once complete and then delete things from there.

    All I was meaning is that in the beginning stages of development, it its easier to have everything under one roof so to speak. Since I'm fairly new, and OP seems to be as well, I can speak from experience here, it is easier to start with it all in one place and go from there. That being said, Joe is correct and has more experience than I do.
     
  8. mrgohut

    mrgohut

    Joined:
    Feb 8, 2014
    Posts:
    134
    Well yeah - i have everything in one procject, but have two scenes - one Server and one Client and they are using different scripts. When i'm building them i do this only one at the time. In my understanting builder include only those scripts that certain scene is using, right?

    And i'm not using any network scripts from unity - i'm making my own using transport layer.
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    How do you know though, if you don't know anything about networking? This isn't a criticism more a heads up you could be leading yourself down a bad path.
     
    tobiass likes this.
  10. mrgohut

    mrgohut

    Joined:
    Feb 8, 2014
    Posts:
    134
    Well first of all I never said that i don't know anything about networking and criticism? Never said that. I'm just asking that's all
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    99% sure we are having language barrier issues :) ignore.
     
    Deleted User likes this.