Search Unity

Question First time using NGO, confused on how to use Network Prefabs for 2 different apps

Discussion in 'Netcode for GameObjects' started by CptanPanic, Feb 2, 2023.

  1. CptanPanic

    CptanPanic

    Joined:
    Dec 19, 2022
    Posts:
    15
    So all the examples I see, people are using multiple instances the same Unity app, but I am trying to setup this to work, whereas the Server and the Client are different apps. Currently how I tried it I get "Failed to to create object locally" and "Failed to spawn networkobject for hash 1225512512"

    So my questions are, 1) Are their any tutorials of this somewhere? 2) On the client side, do I need to register the "Network Prehabs", I am assuming I need to have a similar scene setup on on both sides, at least in terms of the objects, and not nessesarily the locations, as that will get synced.

    Thanks.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    Are you building the two apps from the same Unity project? That is a requirement. The server should be built with the „dedicated server“ target platform from the same project you use to build the client app.
     
  3. CptanPanic

    CptanPanic

    Joined:
    Dec 19, 2022
    Posts:
    15
    No I didn't have it as same project. No way around that? Because want to have apps to be different in such one can have HDRP, different shaders, etc.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    No, it has to be a single project. Otherwise you can only rely on low level transport and implement all the NGO features you need yourself. But nevertheless, it will be a big pain to test and debug a networked project built from two separate projects.
     
  5. CptanPanic

    CptanPanic

    Joined:
    Dec 19, 2022
    Posts:
    15
    Would it be enough to just modify the GUID's of the different objects in different projects to use the same GUID? I guess would need to also modify the scene hash?
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    I would recommend not thinking further into this direction. You would completely leave the space of what's supported, what you would get support for from the community and Unity, and you (as well as anybody outside Unity and probably even most Unity devs too) have no way of knowing what kind of issues you'd run into over time.

    Just how would you go about ensuring one asset gets and retains the same GUID across two projects? There's not even an API for setting the GUID. Sure you could modify the .meta files but only after it has been created, so probably Unity already caches something in the Library folder about that asset using the original GUID. And then how would you synchronize those GUIDs across two projects? And so on ...

    Someone also had the idea of at least enforcing the same network hash used by NGO but you'd still be way out of what is supported.

    You could maybe open another thread asking about why you need two different apps / projects, and if there are any ways to make that work within a single project. (unless you already did - I know some recent threads touched similar topics but can't remember who was asking ;) )
     
  7. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    +1 on this

    @CptanPanic what's your use case? What are you trying to do?
     
  8. CptanPanic

    CptanPanic

    Joined:
    Dec 19, 2022
    Posts:
    15