Search Unity

[Multiplaer] - Players cant see players that logged before.

Discussion in 'Connected Games' started by INSANE_BR, Sep 14, 2009.

  1. INSANE_BR

    INSANE_BR

    Joined:
    Sep 10, 2009
    Posts:
    141
    Hi there, I'v been working with Unity3d for 3 weeks now and I'm focused on the network part.

    Im creating a multiplayer car game. All was going well until I decided I had to create a Scene to connect to the game and a Scene to actually run the game.

    I managed to get my game working with one Scene only, but when I separeteded the Scenes, the new players cant see the players that were already connected on the game.

    My debug says :
    'View ID AllocatedID: 1 not found during lookup. Strange behaviour may occur'

    I am sure Im not missing a Network view on my Prefab and I tried 'DontDestroyOnLoad' on the script from the Connecting Scene.

    Any clue?

    Thanks in advance

    Beneton
     
  2. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,068
    Hello!
    I'm moving this to multiplayer, as the topic is related to multiplayer :D
     
  3. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    978
    You need to instantiate the other players objects on the other clients as well. Use Network.Instantiate for your objects creation instead of having a player(car) object in the scene from start.
     
  4. INSANE_BR

    INSANE_BR

    Joined:
    Sep 10, 2009
    Posts:
    141
    Thanks naruse, I never saw there was a multiplayer session :oops:

    -------

    Leepo, Im actually using Network.Instantiate.

    I have 2 Scenes. Splash and Game.

    At the Splash Screen I make the connection to the server (or create a new server) and 'OnConnectedToServer' or 'OnServerInitialized' I load the Game Scene.

    At the game Scene, on 'Awake' I call 'OnEnterGame' on all game objects and 'OnEnterGame' calls Network.Instantiate.

    It somehow works, because there is interaction between the 2 players, but the player that enter the game last cant see the first player, and for the first player the second player is like a 'god', all interations modify the first player as if the second was invunerable to physics.

    Maybe 'Awake' is not the function I should be using to Instantiate my network objects.. but Im not sure yet.
     
  5. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    978
    Your instantiates get lost in the splash screen; as soon as a client connects it will receive the instantiate information, but since a new scene is loaded, the object will get lost.

    After a successful connection; disable the network communication on the client right away, and disable it as soon as the level has started.

    Use network.IsMessaageQueueRunning or so (check the api or check my networking tutorial.).