# Controlling spawn properties and overriding NetworkManager in Unity

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

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.

• So would this be in place of the network manager? or as well as? – dougajmcdonald Sep 12 '16 at 7:57
• Your new script will replace the default network manager. – greenPadawan Sep 12 '16 at 8:02
• 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? – dougajmcdonald Sep 12 '16 at 8:08
• Yes, it will display all the properties in the UI. – greenPadawan Sep 12 '16 at 11:52
• This worked as expected, thanks. A colleague also told me that the NetworkManager source code is available on Bitbucket if anyone is interested! – dougajmcdonald Sep 12 '16 at 20:09