I’m new in unity multiplayer. Could someone tell me where I have to write my code for OnServerConnected void of the networkManager? I tried to create a script and adding it to my NetworkManager Object, but now I have two networkmanager component. I want it to spawn a ball when two player are connected.
Hello there, you need to create your own NetworkManager or rather create a class that derives from NetworkManager so your CustomNetworkManager will have the same functionality as base one but you can override it’s functions. So create a new component, something like this one:
public class CustomNetworkManager : NetworkManager
{
public override void OnServerConnect()
{
// Voilà
};
}
then you remove your old NetworkManager from your prefab and you add this one. I hope it helps.