Search Unity

Failing OnPlayerDisconnect()

Discussion in 'Multiplayer' started by croniq, Jun 30, 2011.

  1. croniq

    croniq

    Joined:
    Jun 30, 2011
    Posts:
    11
    Hello :)

    So, I've been toying around with the network capabilities of Unity for a little while, and decided to finally make something of it - but, now there is a problem..

    Whenever one of my players disconnect from the server, the OnPlayerDisconnected(NetworkPlayer netPlayer) does not get called on the server.

    I've tracked the Network.connections and the player does indeed loose the connection when calling Network.disconnect().

    Using OnDisconnectedFromServer(NetworkDisconnection info) does not register the disconnect either.

    Odd thing is that OnPlayerConnected(NetworkPlayer netPlayer) gets called just fine.

    The above functions reside inside a public Connection class attached to a gameobject along with a networkView.

    Am I missing something obvious here?

    Thanks in advance for any insight you may have.. :]

    Edit: the title says OnplayerDisconnect() - should have said OnPlayerDisconnected() - just to dismiss the possibility of spelling errors in the script.
     
    Last edited: Jun 30, 2011
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    Should work even without a networkview.
    Can you post your script ?
     
  3. croniq

    croniq

    Joined:
    Jun 30, 2011
    Posts:
    11
    Hi :)

    Thanks for the info - now I know 2 new things.

    1) Networkviews are not required for OnPlayerDisconnected, and...

    2) OnPlayerDisconnected is spelled with a /small/ L .. ><

    And here I was editing to tell everyone it was not a spelling error - lol - Silly fast fingers <<

    Sorry to have wasted your time :)
     
  4. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    yep, syntax is important :)
     
  5. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    You think that's bad - I just had, inside OnPlayerDisconnected, a log message saying: "player has connected!"

    took me two days to figure out what was wrong :)