Search Unity

Strange LeveLoad bug...

Discussion in 'Multiplayer' started by Flynn, Oct 23, 2009.

  1. Flynn

    Flynn

    Joined:
    May 24, 2009
    Posts:
    311
    I'm working on a multiplayer game, based on the multiplayer examples...



    Code (csharp):
    1. @RPC
    2. function LoadLevel (level : String, levelPrefix : int)
    3. {
    4.     Debug.Log("Loading level " + level + " with prefix " + levelPrefix);
    5.     lastLevelPrefix = levelPrefix;
    6.  
    7.     // There is no reason to send any more data over the network on the default channel,
    8.     // because we are about to load the level, thus all those objects will get deleted anyway
    9.     Network.SetSendingEnabled(0, false);   
    10.  
    11.     // We need to stop receiving because first the level must be loaded.
    12.     // Once the level is loaded, RPC's and other state update attached to objects in the level are allowed to fire
    13.     Network.isMessageQueueRunning = false;
    14.        
    15.     // All network views loaded from a level will get a prefix into their NetworkViewID.
    16.     // This will prevent old updates from clients leaking into a newly created scene.
    17.     Network.SetLevelPrefix(levelPrefix);
    18.     Application.LoadLevel(level);
    19.     yield;
    20.     yield;
    21.  
    22.     // Allow receiving data again
    23.     Network.isMessageQueueRunning = true;
    24.     // Now the level has been loaded and we can start sending out data
    25.     Network.SetSendingEnabled(0, true);
    26.  
    27.     // Notify our objects that the level and the network is ready
    28.     for (var go in FindObjectsOfType(GameObject))
    29.         go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
    30. }
    31.  
    32.  
    I keep getting an error at "go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver); ":





    I'm getting this error, in any other scripts that use that line of code.

    I'm completely confused as to what is going on! Any help???
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    did you add all components?
    OnNetworkLevelLoaded is a function that is on one of the components that come with the example actually.
     
  3. Flynn

    Flynn

    Joined:
    May 24, 2009
    Posts:
    311
    Huh. It appeared to be effecting my player spawn, but it was something entirely different. Still, it is a little disconcerting to get an error like this, and I hope it doesn't cause errors...

    Anyways, it turns out to be low priority, but still... Huh.


    @Dreamora I'm not exactly sure what you mean, could you elaborate?