Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Noedel-Man · Jan 06, 2015 at 08:01 PM · networkphotoninternetlan

Lan on photon

Hello,

I just started with Unity and C# and js. And i want to create a Multiplayer game wich is going really good only when a player connects to a server i goes thru photon servers wich is oke for internet and for the server browser to work. but the thing is that i also want player to be able to connect with IP and only over LAN without the signal ever going to the internet. I searched online but i could not find a solution. could you please help me? here is a part of my NetWorkmanager script.

 //start een server
     private void StartServer(){
         Network.InitializeServer(4, 24000, !Network.HavePublicAddress());
         //4 is hoeveel players en 25000 is de port
         MasterServer.RegisterHost(typeName, gameName);
         Debug.Log("Server Started");
 
     }
 
     void OnServerInitialized()
     {
         Debug.Log("Server Initializied");
         SpawnPlayer();
         canvas.SetActive(false);
     }
     //knop
     void OnGUI()
     {
         if (!Network.isClient && !Network.isServer)
         {
             RefreshHostList();
             //moet worden veranderd naar dat hij elke seconde checkt want dit kost heel veel frames
             TextAway();
             if (GUI.Button(new Rect(100, 100, 250, 100), "Start Server"))
                 StartServer();
             //if (GUI.Button(new Rect(100, 250, 250, 100), "Refresh"))
             //    RefreshHostList();
             if (GUI.Button(new Rect(100, 250, 250, 100), "Quit"))
                 Application.Quit();
                 //joinIp("localhost:25000");
         
 
 
 
             
             if (hostList != null)
             {
                 for (int i = 0; i < hostList.Length; i++)
                 {
                     if (GUI.Button(new Rect(400, 100 + (110 * i), 300, 100), hostList[i].gameName))
                         JoinServer(hostList[i]);
                 }
             }
 
 
 
         }
     }
 
     void TextAway(){
         canvas.SetActive(true);
 
     }
 
         
 
         
     //check of er servers zijn
     private HostData[] hostList;
     
     private void RefreshHostList()
     {
         MasterServer.RequestHostList(typeName);
         Debug.Log("Refresh server list");
 
     }
     
     void OnMasterServerEvent(MasterServerEvent msEvent)
     {
         if (msEvent == MasterServerEvent.HostListReceived)
             hostList = MasterServer.PollHostList();
     }
     //join een server
     private void JoinServer(HostData hostData)
     {
         Debug.Log("connecting ...");
 
         Network.Connect(hostData);
     }
     
     void OnConnectedToServer()
     {
         Debug.Log("Server Joined");
         SpawnPlayer();
         canvas.SetActive(false);
     }
     //join ip
     void joinIp(string ip){
         Debug.Log("connecting to " + ip);
 
         Network.Connect(ip);
 
     }
     //spawn een player
     public GameObject playerPrefab;
     private void SpawnPlayer()
     {
         Network.Instantiate(playerPrefab, new Vector3(0f, 50f, 0f), Quaternion.identity, 0);
 
     }
 
 }

I also tried connecting to IP but then i get an error that the server is not connected to photon main server. Iam dutch so all the comments are also in dutch i hope its not a problem :). i can change it if you want.

Comment
Add comment
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 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tobiass · Jan 12, 2015 at 09:02 AM

Photon always uses a dedicated server, so even in a LAN you need a Photon Server running.

There is a redistributable binary package which you could distribute to players, so LAN play is possible. See Exit Games download page.

You can use the Photon Server SDK in combination with PUN (in Asset Store) or the Photon Unity SDK (less comfortable, less clutter, more control). Please refer to the docs to learn how to set your server's address, etc. This is beyond this question.

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 Noedel-Man · Jan 12, 2015 at 12:41 PM 0
Share

oke so which one do i download the server and the client? And how i inport it to my project?

tnx,

avatar image tobiass · Jan 13, 2015 at 04:29 PM 1
Share

I edited my answer. Hope that helps.

avatar image Noedel-Man · Jan 18, 2015 at 02:10 PM 0
Share

i see, thank you.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Send an Animation through photon network 0 Answers

Photon PunRPC problem 0 Answers

Button To Web Address 1 Answer

Upload my Game with Photon -Help 0 Answers

Network RPC find sender gameobject 2 Answers


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