Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Change player position on scene change

Discussion in 'Connected Games' started by DespairBear, Jul 13, 2018.

  1. DespairBear


    Nov 1, 2013
    Hey all,

    Pretty simple question, so I have it setup so player's aren't destroyed when the scene changes and I'm trying to set each player's position to one of the spawn points in the new scene. I'm using the NetworkLobbyManager and was curious what method is the most effective way to get each player's transform position set? I keep running into issues with each method I've tried where the client's position gets changes for a few frames (only visible from the debug console, not to the human eye) but it quickly gets reset.

    I don't believe it's an issue with the character controller as the client is able to set its position just fine. Any tips or thoughts would be greatly appreciated

  2. DespairBear


    Nov 1, 2013
    a bit more info, so this is the code I'm using to set the player position:

    Code (CSharp):
    1. private void Start()
    2.     {
    3.         if (isLocalPlayer)
    4.         {
    5.             SceneManager.sceneLoaded += OnLevelFinishedLoading;
    6.         }
    7.         DontDestroyOnLoad(gameObject);
    8.     }
    10.     public void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
    11.     {
    12.         if( == "Lobby")
    13.         {
    14.             return;
    15.         }
    16.         else
    17.         {
    18.             if(isLocalPlayer)
    19.             {
    20.                 Debug.Log("is local player!");
    21.                 transform.position = GameObject.FindGameObjectWithTag("Spawn").transform.position;
    22.             }
    23.         }
    24.     }
    The host's position is set just fine. However, the client, the position gets set and then is quickly reset back to the position it was in before the scene change.

    Would there be a better more centralized point to put this functionality? Perhaps overriding a method within the NetworkManager? New to multiplayer dev