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 Jellow_ · Aug 22, 2017 at 01:03 PM · serveronline gameconnecting

Can create and play on a server, but not join one.

I am making a 2D multiplayer game and am having a lot of issues, the biggest one being that you are unable to join a server. If you create a server you can control your character and move around, but you cannot even connect to someone else's server, the button to do so just does nothing

When joining someone else's server this is the error message:

Failed to connect to xx.xxx.xxx.xx:50005 because this system is already connected. This can occur when the network connection is disconnected too quickly for the remote system to receive the disconnect notification, for example when using Network.Disconnect(0).

When someone tries to join your server this is the error message:

Receiving NAT punchthrough attempt from target 234187376866924072 failed

here is my NetworkManager script:

 using UnityEngine;
 using System.Collections;
 
 
 public class NetworkManager : MonoBehaviour {
     private const string typeName = "Jellow's 2D Maze Shooter";
     private const string gameName = "GameName";
 
     public GameObject redPrefab;
 
     private void StartServer()
     {
         Network.InitializeServer(4, 25000, !Network.HavePublicAddress());
         MasterServer.RegisterHost(typeName, gameName);
     }
     void OnServerInitialized()    {
         SpawnRed();
     }
 
     void OnGUI()
     {
         if (!Network.isClient && !Network.isServer) {
             if (GUI.Button (new Rect (100, 100, 250, 100), "Start Server"))
                 StartServer ();
 
             if (GUI.Button (new Rect (100, 250, 250, 100), "Refresh Hosts"))
                 RefreshHostList ();
 
             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]);
                 }
             }
         } else if (GUI.Button (new Rect (100,100,250,100), "Disconnect"))
             Network.Disconnect();
     }
 
     private HostData[] hostList;
 
     private void RefreshHostList()
     {
         MasterServer.RequestHostList(typeName);
     }
 
     void OnMasterServerEvent(MasterServerEvent msEvent)
     {
         if (msEvent == MasterServerEvent.HostListReceived)
             hostList = MasterServer.PollHostList();
     }
 
     private void JoinServer(HostData hostData)
     {
         Network.Connect(hostData);
     }
 
     void OnConnectedToServer()
     {
         SpawnRed();
     }
 
     private void SpawnRed() {
         Network.Instantiate(redPrefab, new Vector3(0f, 5f, 0f), Quaternion.identity, 0);
     }
 
 }



Edit: Sorry for bump but I can't find an answer for this anywhere and really need some help with this. :)

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

0 Replies

· Add your reply
  • Sort: 

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

68 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Tanks!!! online question 2 Answers

Question about UNET 0 Answers

Unity Online Not Work 2 Answers

attached prefabs before client joins 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