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

Question Loading Assetbundle With Network Identity

Discussion in 'Testing & Automation' started by Togias, Mar 25, 2019.

  1. Togias

    Togias

    Joined:
    Jul 17, 2017
    Posts:
    6
    My application consists of a server and a client, I load some gameObjects as asset bundles at both server/client. The loaded gameObjects contain network identity and network transform but as I noticed when i load the objects and i move an object from the server it dose not follow its movement at the client.

    I am thinking that the network identity dose not much, as the objects that are loaded are 'not the same'. Any one has an idea on how to overcome this and make the loaded objects much and apply to the network transform. Thank you.
     
  2. Deleted User

    Deleted User

    Guest

    you need to at least manually register the prefabs.
    https://docs.unity3d.com/ScriptReference/Networking.ClientScene.RegisterPrefab.html

    this assures that when network spawning that same prefab on the server, the correct one will also be spawned on the client.
    there's one catch though. If you use the NetworkManager online scene and you allow late joining, the register call needs to be done in Awake. Otherwise it's too late because network traffic will be processed before OnStartClient is called
     
    Last edited by a moderator: Apr 9, 2019
  3. Togias

    Togias

    Joined:
    Jul 17, 2017
    Posts:
    6
    Thank you for the reply, I manage to spawn the objects following the registration/spawn procedure. As I found out there is a Bug in the editor (my unity version 2018.2.5) where you are not able to spawn asset bundles in the network. It works only when the app is built.

    My problem continues even if I managed to spawn the objects because the asset bundles that I spawn are prefabs that inside their hierarchy mone objects with NetID exist. I was thinking that the best solution will be to load the asset bundles and then save them as prefabs.

    Do you have any experience at spawning network objects with nested objects with network Id?

    I also tried to register and spawn all the objects contained at the asset bundles but I had no good results, also the editor bug does not help with debugging...
     
  4. Deleted User

    Deleted User

    Guest

    UNET does not allow nested NetworkIdentities. Whatever you want to do with children of a networked Gameobject, handle them from the root. If they're not meant to be actual children in a sense of networking them, don't child them.
     
  5. Togias

    Togias

    Joined:
    Jul 17, 2017
    Posts:
    6
    Thank you man, I concluded on spawning only the parent objects and then handle the transform of the rest with commands and clientRPC.
     
    Deleted User likes this.