Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Help with Mirror SyncVar and Sceneid

Discussion in 'Multiplayer' started by marti99, May 17, 2021.

  1. marti99

    marti99

    Joined:
    Feb 25, 2018
    Posts:
    3
    Hi guys, i'm making a game with dedicated servers and i need to sync some vars between the server and the client. I started making the client and after i copied it i used it like a base for made the server. At the start i had a NetworkBehaviour script that had the same assetid and sceneid in the client and the server. The problem come when i use ServerChangeScene that give me the error: Spawn scene object not found for x SpawnableObjects.Count=0. I searched online but noone solution worked.

    I think the problem is that i have the object in the server with that info (Image 1) and the server try to spawn the same object on the client without have the object so he don't know what the hell he need to spawn.

    The problem is that the sceneid in the server project and the sceneid in the client project are different so i tried to reset the networkidentity on the script and i had confirmation that the problem is the different value.

    So i think the solutions could be 2.
    - Spawn a prefab with the script in the server and in the client for have the same sceneId
    - Find a way to set the sceneId for have the same value on client and on server

    So, before the NetworkIdentity reset i had the values like the Image1 on client and server but right now i have the Image1 values on the server and the Image2 values on the client

    For try to reproduce that i think you can:
    Create a Project
    Add a NetworkBehavior script that contains syncvar
    Duplicate the project
    Run one as a server (StartServer()) and 1 as a client (CleintScene.AddPlayer(conn))
    Reset one NetworkIdentity on Client or Server script
    And after that try to sync a value from server to client

    I don't know if i explained well but for every any more info i'm here
    Sorry for my bad english but i'm tired it's 3 days that i'm stuck here and i tried 34879156 things and none worked
     

    Attached Files: