Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Photon PUN problem to load a scene with all players in.

Discussion in 'Multiplayer' started by theovsl, May 22, 2023.

  1. theovsl

    theovsl

    Joined:
    May 22, 2023
    Posts:
    3
    Hello, i am using Photon PUN 2 free and i have some issue with it (also i am a debutant in multiplayer). So everything works fine at the start both player can connect on the server and are tp on the hub where they can play with each other. But my problem is when the player want to do the level 1 i used "PhotonNetwork.AutomaticallySyncScene = true;" to tp both player and it is loading the scene "level 1" simultaneously for both player but they are not in the same scene it is loading level 1 for player 1 and another level 1 for player 2 so they are not both in the same scene but in two different scene.

    my code to tp is this:


    it detects if the player is in the zone if he is and press "F" and if he is the master client it will load the level. Could you help me please to figure out how can i tp both player to the same scene.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,991
    So technically they are in the same scene but don't see one another?
    You may have to tell Unity that it should not destroy the player characters on load. Pass all player characters to DontDestroyOnLoad() once on all clients.
     
  3. theovsl

    theovsl

    Joined:
    May 22, 2023
    Posts:
    3
    thank you for your answer. I already have all players in my DonDestroyOnLoad and i dont re instatiate them either. yet when they are teleported they are in the same scene but not in the same. it is like there is two instances of the same scene, one for each player. I looked into the hierarchy of unity when players are teleported and i only see one player and on the screen of others players they are also in the same scene but there is no one.
     
  4. theovsl

    theovsl

    Joined:
    May 22, 2023
    Posts:
    3
    Ok guys sorry I found the problem it was that my DestroyOnLoad was working but not at the same time i dont really know what happened but i did a new script dont destroy which was just "dontdestroyonload(gameObject) " and everything worked fine. i feel stupid but if someone has the same problem as me and is stuck try looking at your dontdestroyonload.