Search Unity

Instantiated prefabs not appearing for new clients

Discussion in 'Multiplayer' started by Stevenup7002, Apr 17, 2009.

  1. Stevenup7002

    Stevenup7002

    Joined:
    Mar 1, 2009
    Posts:
    18
    Hi,
    I'm having a really strange problem that's been bugging me for the past few days. Lets say we have 3 different players. A server player, client 1 and client 2. The server player creates a session, and its player prefab appears in the game. Client 1 then joins the game, everything looks normal on the Server player's screen, he sees Client 1's newly instantiated prefab, and his own, however, Client 1 can only see themself, and not the server player. Client 2 then joins, the server player can now see three players, Client 1 can see himself and Client 2, but client 2 can only see herself.

    In the console for client 1, many errors appear, along the lines of:
    and

    My networking code should be working perfectly, a few days ago, it was running without this strange problem. Then I decided to implement a chat system into the game, after I tried to do that, this problem started happening. And upon ripping that chat system out again, it's still happening. I have a feeling I may have accidentaly deleted a function while I was doing this, however, I'm not sure what I'm looking for.

    Can anyone suggest any causes for this problem?

    Many thanks,
    -Steve :wink:
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    did you use Network.Instantiate?

    Otherwise you will have to have a buffered RPC call for the instantiation. Otherwise the server instantiation will not happen on the other ends as this is your specific duty to handle if you decide to roll your own management solution.
     
  3. Stevenup7002

    Stevenup7002

    Joined:
    Mar 1, 2009
    Posts:
    18
    I found the problem. Turns out the first messages were being sent before the map was fully loaded!

    I fixed it by using
    Code (csharp):
    1. Network.isMessageQueueRunning = false;
    while the map was still loading.

    I hope this topic helps users that may have the same problem in the future :oops:

    Thanks for your help dreamora,
    -Steven
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    sounds like you haven't dived into the network example I guess?
    This and a few other more or less important / interesting things are mentioned there.


    Glad you were able to solve it
     
  5. haxoan87

    haxoan87

    Joined:
    Oct 13, 2009
    Posts:
    11
    I also found this problem , can you show me solution to solve it , ?
    I don't know how to use Network.isMessageQueueRunning
     
  6. Tubeliar

    Tubeliar

    Joined:
    May 21, 2009
    Posts:
    14
    First have a look at the documentation page. It also has a link to an example that shows how to load a level.

    Basically, you just set the variable to true when you want to receive network messages and set it to false when you're not ready to process them yet, typically when not everything is set up yet. Before you start changing things, like when you load a level, set the variable to false to prevent messages arriving for objects that don't exist yet. If the level is set up then set the variable to true and the messages will start coming in.