Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Unity Multiplayer [Workaround found] Canvas misplacements & duplication issue

Discussion in 'Multiplayer' started by Twitwi, Jul 25, 2016.

  1. Twitwi

    Twitwi

    Joined:
    Apr 11, 2012
    Posts:
    22
    It seems like I posted my original thread in the wrong forum. So here is a mirror of the thread (I could not find out to how to remove the old)


    I'm working on semi large project, that I am now trying to make a multiplayer game. However, I have stumpled into a few issues here and there. I have made a git repo that replicates it, which you can find here: https://github.com/Winnak/unitynetworkinglobbytest

    The issues are:
    Duplication on StopHost
    The Unity Networking system is creating a new instance of the LobbyManager (inherits NetworkLobbyManager.cs)

    When LobbyManager.StopHost is called by OnDisconnect from the LobbySlotsPanel, a new instance of the LobbyManager appears in the scene.


    Am I supposed to Destroy the lobby object here, and why?



    UI elements misplaced on Canvas
    This issue appears when a new LobbyPlayer is spawned and then parented the slot. Notice how it works fine on the host, but is misplaced on the clients.


    (A simple fix to this is to set the transform.localPosition of the LobbyPlayer to Vector3.zero on start, but that is a hack and it should be working in the first place.)
     
  2. Twitwi

    Twitwi

    Joined:
    Apr 11, 2012
    Posts:
    22
    isidro02139 likes this.
  3. isidro02139

    isidro02139

    Joined:
    Jul 31, 2012
    Posts:
    72
    Twitwi, I have a similar issue re: the UI elements misplaced (screenshots of the host and remote client linked below). Weird thing is, it wasn't happening yesterday, I wonder if it's related to the NetworkIdentity component on my ui? What are your NetworkIdentity settings for the ui in question?

    Regarding the forums in general:
    1) I heard from someone at Unity that it's impossible to delete old threads, and that once they get old it's better to make a new thread then reply / add to existing threads (your own or someone else's). Unity mods, please correct me if I'm wrong here..

    2) Definitely better to separate each issue into multiple posts imho, it just makes the communication simpler for all involved.

    Arun

    Screenshots of ui discrepancy between host and remote client:
    http://imgur.com/gallery/hGy9j
     
    Twitwi likes this.
  4. Twitwi

    Twitwi

    Joined:
    Apr 11, 2012
    Posts:
    22
    I believe they were set to player authority.

    If you mean my previous thread (aka the one on community.unity.com) my issue there was that they locked the entire forum, shortly after I posted leaving no one able to respond. If you meaning this thread, as in, I should create a new thread instead of just bumping it with updates, ok but that seems kinda weird to me.

    But yea, I should have. I thought that these were the only 2 bugs I would stumble upon ¯\_(ツ)_/¯ (optimism at its finest)
     
    isidro02139 likes this.
  5. isidro02139

    isidro02139

    Joined:
    Jul 31, 2012
    Posts:
    72
    fwiw (for what it's worth) I agree that creating lots of new posts instead of continuing older ones where (presumably) more relevant information and dev/user feedback has been gathered seems strange, but that's what I heard!! Maybe someone from Unity can chime in... Anyone? (I don't think anyone has time to read the forums that regularly though, this is a good example of why making a new post may be better!)
     
  6. FullDiver

    FullDiver

    Joined:
    Jun 13, 2017
    Posts:
    3
    I don't know if anyone is still following this thread, but I've found the root of the problem, and a solution.

    The problem is that StopServer() (StopHost() contains calls to StopServer() and StopClient()) contains a call to change the scene to NetworkManager.offlineScene, which gets overridden by NetworkLobbyManager.lobbyScene. So when you call StopHost() in the lobby scene, you're essentially trying to reload the scene with the already existing DontDestroyOnLoad LobbyManager, which causes some issues.

    This can be easily fixed by adding the line
    Code (CSharp):
    1. void Start(){
    2.     offlineScene = "";
    3. }
    to the code (or just appending it to your existing Start() function.

    This is probably already a dead thread, but I figure it would be better to post this solution than not.
     
    Twitwi likes this.
unityunity