![]() ![]()
For now, we are happy to get feedback telling us the server is actually initialized.Īll we need now is some form of input to let us actually start the server when we want to. If the server is successfully initialized, OnServerInitialized() will be called. MasterServer.RegisterHost(typeName, gameName) Network.InitializeServer(4, 25000, !Network.HavePublicAddress()) Private const string gameName = "RoomName" Private const string typeName = "UniqueGameName" Add these lines to the NetworkManager script. The room name can be any name, and in our case we eventually used the player name. #NETWORKVIEW RPC FUNCTIONS ARE DEPRECATED REGISTRATION#For the server registration the name of the game should be unique, otherwise you might get in trouble with others projects using the same name. The initialization requires a maximum amount of players (in this case 4) and a port number (25000). To create a server, we need to initialize it on the network and register it to the master server. It will handle hosting a server or connecting to an existing server. Add this empty script to an object in the scene, either the camera or an empty game object. So let’s get started! In the new Unity project, create a new C# script named “NetworkManager”. It’s explained in Javascript, but covers the same content as the first three paragraphs. Networking was a new topic for us and I found this video tutorial very useful to start with.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |