Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Combinacijusx · Oct 30, 2015 at 02:00 PM · unity 5networking

Unity UNET how to connect to local network(same wifi)

So I'm trying to make game in which you can connect to friends if they are connected to same wifi router without internet. On same computer I can host game an then join in other game window but I can't figure out how to join between two computers on same wifi. Anyone can help? Documentation, sample projects, tutorial anything?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image milad3d · Apr 22, 2016 at 02:44 PM 0
Share

is it work in two android device?

7 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Endless_Aftermath · Oct 30, 2015 at 02:34 PM

Here's a login program that I made from a youtube tutorial here... https://youtu.be/v4cXuiZyJQ8 .

I commented a lot of this out to help teach my son learn networking. This tutorial will show (pretty simply) how to connect and share information over LAN/WiFi. Hope this helps.

 using UnityEngine;
 using System.Collections;
 public class Menu : MonoBehaviour 
 {
 
     public string ip = "169.254.17.167";
     public int port = 25000;
     
     void OnGUI()
     {
         //if the player is NOT connected
         if(Network.peerType == NetworkPeerType.Disconnected)
         {
             //this is temporary for input of the ip address
             //find out your ip address and assign it here during gameplay
             ip = GUI.TextField(new Rect(200, 100, 100, 25), ip);
             port = int.Parse(GUI.TextField(new Rect(200, 125, 100, 25),""+ port));
             
             //if the player wants to connect to a server
             if(GUI.Button(new Rect(100,100,100,25), "Start Client"))
             {
                 //this is where we actually connect to the server
                 Network.Connect(ip, port);                
             }
             
             //if the player wants to start a server
             if(GUI.Button(new Rect(100,125,100,25), "Create Server"))
             {
                 Network.InitializeServer(10, port,false);
             }
         }//end of "if the player is NOT connected"
         
         else //if the player IS connected
         {
             if(Network.peerType == NetworkPeerType.Client)
             {
                 //letting the player know that they are a client to a server
                 GUI.Label(new Rect(100,100,100,25), "Client");
                 
                 //if the player wants to disconnect
                 if(GUI.Button(new Rect(100,125,100,25), "Logout"))
                     Network.Disconnect(200);//the 200 is in milliseconds for the disconnect
             
             }
             
             if(Network.peerType == NetworkPeerType.Server)
             {
                 //letting the player know that they are a server
                 GUI.Label(new Rect(100,100,100,25), "Server");
                 
                 //this shows how many people are connected to your server
                 GUI.Label(new Rect(100,125,100,25), "Connections: " + Network.connections.Length);
                 
                 //if the player wants to disconnect
                 if(GUI.Button(new Rect(100,150 ,100,25), "Logout"))
                     Network.Disconnect(200); //the 200 is in milliseconds for the disconnect
             
             }
         }//end of "if the player IS connected"
         
     }
 }
 
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Combinacijusx · Oct 30, 2015 at 10:36 PM 0
Share

It's not UNET, but thanks a lot, I just typed IP ins$$anonymous$$d of localhost and now I can connect via wifi. Thanks!

avatar image PiFLYON · Nov 03, 2016 at 12:45 PM 0
Share

Hi, When you say in your script :

(37) //letting the player know that they are a client to a server

(48) //letting the player know that they are a server

What do you mean by "they are a..." ? Do you mean "there is a..." or "he is a..." or something else ?

Thank you.

avatar image alexhapki · Apr 06, 2020 at 09:28 AM 0
Share

Hi @$$anonymous$$dless_Aftermath, Thank you very much for taking the time to share this with us. It works marvelous well and it is simple enough, a fine combination. I only added a piece of code to take the local IP address to show;

     void Start()
     {
         string localHost = Network$$anonymous$$anager.singleton.networkAddress;
         IPHostEntry host;
         string localIP = "";
    
         host = Dns.GetHostEntry(Dns.GetHostName());

         foreach (IPAddress ipGO in host.AddressList)
         {
             if (ipGO.AddressFamily == AddressFamily.InterNetwork)
             {
                 ip = ipGO.ToString();
                 Debug.Log(ip);
                 break;
             }
         }    
     }

 
avatar image
0

Answer by martinajain11 · Oct 15, 2018 at 12:37 PM

I have Linksys WRT1900AC AC1900 Dual-Band Wi-Fi Router" Linksys router, After the installation, I connected a Lan with a modem to access an internet via Laptop but I can't find the local address to connect two different systems. It seems like I'm not able to connect with them. Can I contact Linksys support experts at https://www.routertechnicalsupportnumbers.com/linksys-router-support/ or not. Your support is precious to me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tanjawl45645 · Jul 18, 2019 at 10:40 AM

I was trying to do it, but before it succeeds it creates an error, may I ask how can I resolve this or could you please provide me a brief description to the point. Besides this should it possible to take help for the issue from D-Link Router Customer Support from http://www.routercustomercare.co/blog/how-to-fix-d-link-router-errors-103/ please reply me.,I was trying your tips, but unfortunately, there occurs an issue due to which it cannot be possible. Could you please, provide me the brief description or points? Is it able to get help from D-link router customer support from http://www.routercustomercare.co/blog/how-to-fix-d-link-router-errors-103/ . please reply me .

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by evagrey · Jul 29, 2019 at 11:36 AM

Even I made a same attempt to do so, however, I failed to succeed in it. But to secure my all online activity, I download AOL Shield Support which is working as a safety guard for all my online works. Besides, for my further queries I visited their website for help and found it useful.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by eja67 · Oct 25, 2020 at 08:49 AM

Hi @Endless_Aftermath, i done but in my phone i can not connect to PC, can you help me to do that!,

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

57 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Client side Player prefab spawned by overriding GameManager return false for isLocalPlayer 0 Answers

Is unity uses rendering from the cpu or gpu ? 2 Answers

how can i pickup a weapon and drop it on certain key press?(unet) 0 Answers

How can a client connect more players to a network game? 1 Answer

Time.time is influenced by the performance? Can i use it in a multiplayer game? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges