- Home /
Need help with basic networking
Hello there. Im sorry to bother. Im kinda frustrated with unity networking, as I found that the examples, guides or even the m2h guide dont work or has errors on unity 3.*. I dont know about the m2h updated version as I cant afford U$s85 for a tutorial. Its probably a great thing, just out of my possibilities. I looked at youtube examples, 3rd party sites and most link in the unity community answers, but I cant find answers to what I need. I would like a simple basic guide to connecting 2 computers (server and client). I dont want things done, I would like to understand and learn what I need to do. Sorry I bothered and here's hoping that someone can throw some light to the matter.
P.s. I want to use unity's built in functionality and classes. I dont want to use smartfox or any other third party solution.
Thanks. I hope someone has any answer for me.
Well first of all, many thanks for the fast replies. I am now checking s$$anonymous$$mis videos. As I said I already have that m2h old version and cant afford the U$s 85 for a tutorial. I though I was clear (again sorry if this sound rude, its not my intention at all, I really appreciate that all of you took the time to try and give me a hand). Well I will try to make something out of all that. One other question that Im struggling with is, I want to create a server, but it shows my private ip so my example works only when I test it locally.
here is the code Im using.
var remoteIP = "127.0.0.1"; var remotePort = 25000; var listenPort = 25000; var useNAT = false; var yourIP = ""; var yourPort = "";
function Update () { }
function OnGUI () { // Checking if you are connected to the server or not if (Network.peerType == NetworkPeerType.Disconnected) { // If not connected
if (GUI.Button (new Rect(10,10,100,30),"Connect"))
{
// Connecting to the server
Network.Connect(remoteIP, remotePort);
}
if (GUI.Button (new Rect(10,50,100,30),"Start Server"))
{
// Creating server
Network.InitializeServer(32, listenPort,useNAT);
// Notify our objects that the level and the network is ready
for (var go : GameObject in FindObjectsOfType(GameObject))
{
go.Send$$anonymous$$essage("OnNetworkLoadedLevel", Send$$anonymous$$essageOptions.DontRequireReceiver);
}
}
// Fields to insert ip address and port remoteIP = GUI.TextField(new Rect(120,10,100,20),remoteIP); remotePort = parseInt(GUI.TextField(new Rect(230,10,40,20),remotePort.ToString())); } else { // Getting your ip address and port ipaddress = Network.player.ipAddress; port = Network.player.port.ToString();
GUI.Label(new Rect(140,20,250,40),"IP Adress: "+ipaddress+":"+port); if (GUI.Button (new Rect(10,10,100,50),"Disconnect")) { // Disconnect from the server Network.Disconnect(200); } } }
But if tested on the net it doesnt work. $$anonymous$$aybe Im doing something wrong. I believe it must be something with useNat.
I dont have a public IP, so there must be my issue.
Any hints will be great =). Thanks anyway up to this point.
Answer by Hamesh81 · Mar 13, 2012 at 07:32 PM
Steamis50's youtube channel has quite a large number of Network related videos (and others also). It is quite a long tutorial series but as far as I know the most comprehensive and free one available. Check it out here. You'll have to work out his strange video naming convention but most of the network stuff is back to back. Enjoy, and give me a shout if you find any better material!
Answer by Meltdown · Mar 13, 2012 at 06:13 PM
Check this out...
http://forum.unity3d.com/threads/29015-UniKnowledge-entry-Unity-Networking-the-Zero-to-Hero-guide
He has an improved version on the asset store, but it seems a free version in the thread you can download, which should be enough to get you started.
The latest post in that thread has an updated download link. http://www.mediafire.com/?5qtuxk1j9gqodi9
How sneaky! $$anonymous$$y bad you're right, someone's 'sharing' $$anonymous$$ike's old guide. Hopefully he's ok with that as I'd say there's a reason why he took it down haha. Thanks for the link!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity networking tutorial? 6 Answers
Help with server creation and handling. 0 Answers
Networking Player Nametag 1 Answer
Can i make multiplayer game without unity multiplayer service ? 1 Answer