Hello there! Today I am going to be explaining how you can start running multiplayer servers off of one client, using the Unity engine of course.
To start off with, you need to have already made sure this is a scene running off of a different executable, just so that you have one client and one server and you aren't trying to mix them together =)
By the way this is all in JavaScript =)
Step 1)
Make a new function that will start your server
for example:
in this function you need to start writing the code for the master server (Unity's Server)
Then use this to make sure this server has a public version of their ip address:
Finally, this is where you need to make sure which integer is which. The first int is the max connections, the second int is the port number, next is the useNat variable (I talk about this later)
Alright, it may seem like you are done but we need to actually start the server first. Remember that function we made earlier? We use that in the function Start () function so that is starts up automatically when we startup the server's executable.
Edit: A little bit more to go!
Now let's register our server with Unity
And make sure our server is dedicated
Done! Now make sure to add this script to an empty gameobject and run it on startup, now you have a dedicated server executable! Awesome!
Have any comments? Leave them down below, and I'll answer!
Last edited by BryceCain25 on Thu Mar 19, 2015 4:27 pm; edited 1 time in total (Reason for editing : Missing issues that are now adressed via the MasterServer registration)
To start off with, you need to have already made sure this is a scene running off of a different executable, just so that you have one client and one server and you aren't trying to mix them together =)
By the way this is all in JavaScript =)
Step 1)
Make a new function that will start your server
for example:
Code:
function StartServer () {
}
in this function you need to start writing the code for the master server (Unity's Server)
Code:
Network.incomingPassword = "YourPasswordHere"
Then use this to make sure this server has a public version of their ip address:
Code:
var useNat = !Network.HavePublicAddress();
Finally, this is where you need to make sure which integer is which. The first int is the max connections, the second int is the port number, next is the useNat variable (I talk about this later)
Code:
Network.InitializeServer(32, 25000, useNat);
Alright, it may seem like you are done but we need to actually start the server first. Remember that function we made earlier? We use that in the function Start () function so that is starts up automatically when we startup the server's executable.
Code:
function Start () {
StartServer(); }
Edit: A little bit more to go!
Now let's register our server with Unity
And make sure our server is dedicated
Code:
MasterServer.dedicatedServer = true;
Code:
MasterServer.RegisterHost("GameType",
"GameName","Name");
Done! Now make sure to add this script to an empty gameobject and run it on startup, now you have a dedicated server executable! Awesome!
Have any comments? Leave them down below, and I'll answer!
Last edited by BryceCain25 on Thu Mar 19, 2015 4:27 pm; edited 1 time in total (Reason for editing : Missing issues that are now adressed via the MasterServer registration)