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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Multiplayer game using two different projects

Discussion in 'Multiplayer' started by jose-araujo, Mar 7, 2018.

  1. jose-araujo

    jose-araujo

    Joined:
    Nov 17, 2016
    Posts:
    34
    Hi, I have created two projects where each scene has a player as implemented in the Multiplayer Network Tutorial https://unity3d.com/learn/tutorials/s/multiplayer-networking using a Network Manager. When I build and run a single project and simultaneously run that same project in the editor, then things work fine as in the tutorial. However, when I build and run each project separately, or run the editor of each project separately, then I get the error message "Failed to spawn server object, did you forget to add it to the NetworkManager? assetId=10a722dbb60160542b789e20d437496e netId=2
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()" in the client side. Any idea why this is the case?

    Interestingly, when I use the NetworkClient and NetworkServer implementation in the same case, I manage to exchange messages between the client and the server on the different projects. Its just this case with the network manager that doesnt seem to work.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The higher level stuff of the Unet HLAPI is built with the assumption that the client and server are both the same project, and are running the same scene. The mid level Unet Messages can work outside of that, as well as the LLAPI.

    There was a thread or two some months back where someone was trying to get it to work with multiple projects, and was able to get some success after putting in a considerable amount of work. Also the HLAPI source is available for you to download and look through.
     
    Last edited: Mar 7, 2018
  3. jose-araujo

    jose-araujo

    Joined:
    Nov 17, 2016
    Posts:
    34
    Thats great to know @Joe-Censored... been breaking my head for some days on this.

    Is it possible to use the LLAPI and instantiate and spawn objects from a server? What I wanted to do is just to be able to create several objects in a server and then have them appearing in a client with their transform synched with the transform of the server.

    Thanks again!
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Yes you certainly can do that, but will have to build a system of instantiate/spawning objects on top of the LLAPI yourself, as the Low Level API doesn't have any of that higher level functionality built in out of the box.

    I haven't used the LLAPI much, but I'd assume you'd create a system where you assign all your prefabs you would want to instantiate across the network their own unique ID's, then have the server tell all clients to instantiate the prefab matching the ID of the one you instantiate on the server. Then you'd need to write a system for syncing position/rotation between objects, which also probably means you need a system for uniquely identifying instantiated objects separate from uniquely identifying prefabs, so you can direct sync updates to the correct object in the game world.
     
  5. jose-araujo

    jose-araujo

    Joined:
    Nov 17, 2016
    Posts:
    34
    Thanks a lot! Have to think if I should go for that or re-design the whole thing to be in the same project and scene. In the meantime will also try to see if I can find that post you mentioned of the person that succeed with the HLAPI.