Search Unity

Does a Unity Server have a NetworkPlayer instance in Network.player?

Discussion in 'Scripting' started by BmxGrilled, Sep 19, 2014.

  1. BmxGrilled

    BmxGrilled

    Joined:
    Jan 27, 2014
    Posts:
    239
    Hi, my question is simple, I'm wondering if when a game is initialized as a server, does it have a NetworkPlayer object assigned to Network.player ? or is it just for clients?
     
  2. BmxGrilled

    BmxGrilled

    Joined:
    Jan 27, 2014
    Posts:
    239
    Apparently not, as my experimentation has found out so far. Good to know, not to assume that if Network.isServer == true, Network.player == server, Network.player == null!
    ;)
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Thanks for reporting your findings! (I'm holding off on delving into Unity's networking too much until the new stuff in 4.6, which looks pretty cool.)
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Yeah it's very odd. One other thing to note - if you Network.Instantiate something as the server it will correctly report that you own it (networkView.isMine == true) but if you attempt to RPC to that player you'll get an error saying the player isn't connected.

    I've documented some other edge cases here: http://forum.unity3d.com/threads/some-gotchas-i-just-found.199051/
     
  5. Fraconte

    Fraconte

    Joined:
    Dec 6, 2013
    Posts:
    327
    New networking stuff? Is it in beta too?
     
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Oops, sorry, it's not coming in 4.6; it's coming in 5.x. Here's a video of the session:

     
    Fraconte likes this.