Search Unity

Question Prefab instance placed manually in editor is not recognized as related to prefab by netcode?

Discussion in 'Netcode for GameObjects' started by MaxYari, Apr 19, 2022.

  1. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Hello there!

    I'm trying to equip weapons on the server when the client clicks on it. I do that by catching a click on a weapon object and instantiating it into the player's hand. The weapon is a prefab and this prefab is registered in network prefabs. If I spawn a weapon into the game world upon game start - everything works alright, yet if I place prefab in the editor and then launch the game - I can see that placed prefab now has a different `GlobalObjectIdHash` and attempt to Instantiate it causes.

    upload_2022-4-19_20-18-19.png

    So it seems to me, `GlobalObjectIdHash` link is lost whenever the prefab is placed in the scene in the editor. Is that intended? And if so - what will be a recommended workaround?
    Thanks!
     
    browne11 likes this.
  2. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Did you make any changes to the prefab in the scene? If so it's not really the "Same Prefab". I have prefabs in scene that are registered to the network manager and its working AOK.
     
  3. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    138
    We are having this exact same issue as well.
     
  4. browne11

    browne11

    Joined:
    Apr 30, 2015
    Posts:
    138
    I assume he is spawning the prefab without an instantiation. We simply call .Spawn() since no instantiation is needed as it's already in the scene..