- Home /
how to test your multiplayer game
I want to ask on how to be able to test if my multiplayer game is working before building it. is this possible? if yes, how?
Hire a number of top-flight $$anonymous$$P developers, buy a tremendous amount of equipment, formulate a healthcare plan, take care of local government regulations for employees, deal with unions, get a good accountant and secretary, and get to work. :-/
Can you please post the line of code that sets up your network and the one that connects your client? I have no idea what I'm doing wrong here, but it just won't seem to connect to localhost.
Hi @JustAGuy, I was have exactly the case you mention with the server in one project and the client in another project.
For some reason, when I set the host in one project and the client in the other project, I get the error message "Failed to spawn server object, did you forget to add it to the Network$$anonymous$$anager? assetId=10a722dbb60160542b789e20d437496e netId=2 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()", while if I run just a single project in the editor and build the same project, then everything works. I tried also running the editor/build in one project and the build in the other, and I get the same error. I also set "run in background" as you suggest but no effect.
An interesting thing is if in each of these projects I use the NetworkClient and NetworkServer without a Network$$anonymous$$anager, then I can do message passing between the two projects without any errors.
Any idea why I could be having this problem?
Dont ask questions and post them as answers, especially on old threads. Write a new question
Answer by senad · Feb 07, 2012 at 02:08 PM
I have a multiplayer project and I test by using two instances on the same computer using the localhost ip address. One I build and run, the other I run in the editor.
I can currently only debug the one running in the editor however. So maybe I will soon start testing with two separate machines/PCs.
@senad: I am trying to figure out how to do exactly that. Can you explain in detail or point me to a place that shows clearly how to do the 2 instance localhost thing? I am relatively new to unity and stumped!
So I have separate builds for the server and client. I build them as executables on windows and can start each in its own thread on the same machine.
The process that I need to debug I keep in the editor.
When connecting the client to the server ins$$anonymous$$d of a IP address I use "localhost". You could use 127.0.0.1, too.
Unfortunately, I can not direct you to online tutorials, because I learnt this at Uni. :)
Edit: Corrected the IP.
Is your machine connected to the internet? When I set up a server it always uses my internet connection IP. So 1.0.0.127 doesn't seem to work. Part of it seems to be the port... what port do you use for your client and server?
If you are using localhost, it does not matter, what your computer is connected to, as long as you have a network device. The server is listening to your local IP of your computer. That would normally be the IP you get from your DSL router, if you are in a home network. (but it does not really matter)
On the client you type in 'localhost' as the IP. This will connect you to the server on your local machine automatically.
The port you need to chose, but I use a fixed IP on client and server. It should not be used / reserved and should be the same on client and server. I think I use something like 25000.
I hope it helps! :)
@senad You have the loopback address backwards. It should be 127.0.0.1. @sun_spider that is why you cannot get it to work, but don't worry about it because using 'localhost' does the exact same thing. No need to try both.
Answer by UScripter · Jan 24, 2015 at 11:22 PM
A mulitiplayer game can be tested by building the project and play with the build and with unity's editor(If u have one program for server and client).If u have two programs just play the server in the editor and play the client in the editor each in its project(and build the client and play with it too if u want two clients).
NOTE:when testing networking in the editor make sure "Run in background" is checked on (by opening Edit-> Project Settings-> Player then check "Run in background" from the inspector)
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
setup a php master server 2 Answers
Network Tutorial Interpolation - TPS Auth 0 Answers
Instantiated objects does not appear on clients when connecting 1 Answer
hovering usernames with photon 1 Answer