Search Unity

Game Object Inative after Load seconde scene

Discussion in 'Multiplayer' started by rickikki, Mar 7, 2019.

  1. rickikki

    rickikki

    Joined:
    Oct 9, 2018
    Posts:
    13
    Hello,

    I work for learn unet ( i know will become obsolete) but i whant understand :)

    I have make basic game 2D game.

    I have lobby for chose player prefab.

    When player chose avatar and push start that start the first level.

    The first level work .

    My player1 ,player2, Prefab are active and the action of player are syncro ( jump ,fire,move,health,stats,)

    Every monster ( game object with script be active)

    I can kill all monster.

    The probleme become when i whant load scene 2

    I have make collider on the map , when player move on the collider that load level 2.

    But when i load level 2.

    All my monster are inactive.

    I dont understand why.

    Only the scene after the lobby work full.

    I think is one classic error but i dont find.

    I need some help.

     
    Last edited: Mar 7, 2019
  2. LukeDawn

    LukeDawn

    Joined:
    Nov 10, 2016
    Posts:
    404
    Are all your networking scripts/managers on a GameObject with DontDestroyOnLoad so they remain as the scene changes or are you loading the next scene additively?
     
  3. rickikki

    rickikki

    Joined:
    Oct 9, 2018
    Posts:
    13
    I use this for load scene A2.

    I have dont destroy script on player préfab.




    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Networking;
    6. using UnityEngine.SceneManagement;
    7.  
    8.  
    9. public class LoadLevel2Script : NetworkBehaviour {
    10.  
    11.     void OnCollisionEnter2D(Collision2D col){
    12.  
    13.         Application.LoadLevel ("A2");
    14.  
    15.     }
    16. }
    17.  
    18.  
     
  4. LukeDawn

    LukeDawn

    Joined:
    Nov 10, 2016
    Posts:
    404
    Have you made sure that your NetworkManager script is still in the scene when A2 is loaded?
     
  5. rickikki

    rickikki

    Joined:
    Oct 9, 2018
    Posts:
    13
    Last edited: Mar 8, 2019
  6. rickikki

    rickikki

    Joined:
    Oct 9, 2018
    Posts:
    13
    Is ok.

    I find the probleme.


    Application.LoadLevel ("A2");

    Dont work.

    i use this now

    NetworkManager.singleton.ServerChangeScene((SceneManager.GetActiveScene().buildIndex + 1).ToString());
     
    Last edited: Mar 10, 2019