- Home /
I need Help with Multiplayer I can server but not use client
I have some multiplayer code, and I know it works because I have confirmed it with other players who are using the same code. It's the generic code where you can type in your name, ip, and connect or host on the top left, im sure we all know which code im using.
I am trying to connect a client and a server locally on my computer. I have been able to host a server, but I cannot connect to the server locally with my client.
My default gateway is 192.168.2.1
When I try to host on 192.168.2.1 it lets me. When i try to connect on this same ip with another instance of the game as client, it will not let me do it. I have tried many different combinations of ips, ports, and clients. Nothing is working.
What am I doing wrong, this is really costing me a lot of time? Usually I can figure this stuff out on my own very easily but I have run into a BRICK WALL.
No i dont have firewalls, routers, nothing. All third party disabled. I just want to be able to connect my client and server instances locally on my computer. I am being as specific as I can without posting the generic code and telling you guys what my favorite color is.
I'm a bit confused. Why do you tell use your default gateway? A gateway is a router and only necessary when you want to reach an IP outside of your local subnet.
You said you hosted your game on 192.168.2.1 but that looks like the IP of a FritzBox or any other router. Are you sure you know the IP of both PCs and that you use the correct one?
btw. Just to be sure: you talk about Unity's network engine (Raknet), right? In other words UnityEngine.Network.Connect() / InitializeServer()
?
Answer by Dreamside · Feb 27, 2012 at 12:50 PM
Are you running client from Unity itself or from a build? I just tried to do the same ,i build the game and create a server from unity itself and a client from my build.
In my second experiment i used local ip 127.0.0.1 and it also worked.
Answer by Bunny83 · Feb 27, 2012 at 01:45 PM
You propably forgot the most important thing for server-client applications in Unity:
You have to check Run-In-Background in the ProjectSettings or via scripting.
Otherwise the server can't process the connect of the client because it doesn't have the focus. When you switch over to the server it will process the connect, but the client doesn't react to that since the client is now in background.
bunny83 thank you so much. my multiplayer now works. i added the Application.runInBackground = true; to one of my start functions and presto.
Answer by gooncorp · Apr 25, 2012 at 06:59 AM
thanks guys. yea it was the run in backround thing. i just realized someone had answered this. thanks again.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I have this script here for multi player and I cant seem to find the compiler errors. 1 Answer
Multiplayer Help? 0 Answers
Unity networking tutorial? 6 Answers
setup a php master server 2 Answers