I'm trying to find the best approach to controlling the spawn process in a multiplayer unity game.

Having looked over the docs, I have a NetworkManager and it's easy enough to set a player prefab and some other registered prefabs.

What I need to do, it randomly pick the prefab that the player spawns as (from a predefined set).

Having looked over the docs and tutorials I have found two potential options but have not managed to implement either.

a) Override the network manager and provide an implementation of OnServerAddPlayer as per this page: https://docs.unity3d.com/ScriptReference/Networking.NetworkManager.OnServerAddPlayer.html

  • With this approach I'm not sure how to attach my overridden network manager class to the scene. Do i add it as a component to the NetworkManager? Do I remove the network manage and use this script instead?

b) Provide a spawn manager class as per this page: http://docs.unity3d.com/Manual/UNetCustomSpawning.html

  • With this approach I'm also unsure how to attach the spawn manager to the rest of the scene. I've tried adding it in the hierachy within an empty game object, but I'm unsure then how to make use of it within my NetworkManager. The docs only give examples of using it to control bullets being created programmatically.

Afraid I'm quite new to unity and just trying to get to grips with the basics. Would really appreciate some pointers on this one.


1 Answer 1


You can follow the first approach and you can attach it in the same way as you attach the default NetworkManager, i.e. create a game object and attach your new script to it.

  • \$\begingroup\$ So would this be in place of the network manager? or as well as? \$\endgroup\$ Sep 12, 2016 at 7:57
  • \$\begingroup\$ Your new script will replace the default network manager. \$\endgroup\$ Sep 12, 2016 at 8:02
  • \$\begingroup\$ Great, I'll give that a whirl as soon as I can, presumably the overridden class would still display the existing NetworkManager properties in the UI? \$\endgroup\$ Sep 12, 2016 at 8:08
  • \$\begingroup\$ Yes, it will display all the properties in the UI. \$\endgroup\$ Sep 12, 2016 at 11:52
  • \$\begingroup\$ This worked as expected, thanks. A colleague also told me that the NetworkManager source code is available on Bitbucket if anyone is interested! \$\endgroup\$ Sep 12, 2016 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .