Search Unity

Resolved To many prefabs, Network Prefabs List

Discussion in 'Netcode for GameObjects' started by RoWatts, Nov 14, 2022.

  1. RoWatts

    RoWatts

    Joined:
    May 5, 2022
    Posts:
    6
    We have a huge problem. (And we are very new to multiplayer and Netcode)
    We create a random arena (between 4) with random tile types. Every tile type is a prefab, so we have something like 100 (a few less) prefabs in the assets. The arena is generated server side and clients see it.

    How can we avoid adding to the Network Prefabs List, 100 prefabs (network gameObjects)?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,990
    How is that a huge problem?

    If this is about not wanting to do 100 drag&drop operations manually I'm certain an editor script could be written easily that does this job for you, provided those prefabs are identifiable/categorizable by name/path or base class of a script or tag or probably a couple more things.
     
    RoWatts likes this.
  3. CosmoM

    CosmoM

    Joined:
    Oct 31, 2015
    Posts:
    204
    You can also avoid this by writing your own prefab handler. See here.
     
    RoWatts likes this.
  4. RoWatts

    RoWatts

    Joined:
    May 5, 2022
    Posts:
    6
    thank you so much we're now trying these solutions :)
     
  5. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    I'd also add that if the tiles are just "static" and don't really do any kind of interaction (I.E: are spawned only at the beginning of the match and are not destructible), you could avoid handling their spawn over the network to save bandwidth and instead send the IDs of the tiles to spawn, do a lookup on the client and spawn them locally