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
1
Question by jukenos · Mar 04, 2013 at 07:46 PM · multiplayerothercannotseeeach

Can't see each other in multiplayer

Hey there. I have a problem with my unity game, I can connect to my friend, he can connect to Me, but we can't see each other. Any help?

That's my multiplayer script:

 using UnityEngine;
 using System.Collections;
 using System;
  
 public class MPBase : MonoBehaviour 
 {
  
     public string connectToIp = "127.0.0.1";
     public int connectPort = 25000;
     public bool useNAT = false;
     public string ipaddress = "";
     public string port = "";
  
     string playerName = "<NAME ME>";
  
     void OnGUI()
     {
         if (Network.peerType == NetworkPeerType.Disconnected)
         {
             if (GUILayout.Button("Connect"))
             {
                 if (playerName != "<NAME ME>")
                 {
                     Network.useNat = useNAT;
                     Network.Connect(connectToIp, connectPort);
                     PlayerPrefs.SetString("playerName", playerName);
                 }
             }
  
         if (GUILayout.Button("Start Server"))
         {
             if (playerName != "<NAME ME>")
             {
                 Network.useNat = useNAT;
                 Network.InitializeServer(32, connectPort);
  
                 foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
                 {
                     go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
                 }
                 PlayerPrefs.SetString("playerName", playerName);
             }
         }
             playerName = GUILayout.TextField(playerName);
             connectToIp = GUILayout.TextField(connectToIp);
             connectPort = Convert.ToInt32(GUILayout.TextField(connectPort.ToString()));
         }
         else
         {
             if (Network.peerType == NetworkPeerType.Connecting) GUILayout.Label("Connect Status : Connecting");
             else if (Network.peerType == NetworkPeerType.Client)
             {
                 GUILayout.Label("Connection Status : Client!");
                 GUILayout.Label("Ping to Server: " + Network.GetAveragePing(Network.connections[0]));
             }
  
             else if (Network.peerType == NetworkPeerType.Server)
             {
                 GUILayout.Label("Connection Status : Server!");
                 GUILayout.Label("Connections: " + Network.connections.Length);
                 if (Network.connections.Length >= 1)
                     GUILayout.Label("Ping to Server: " + Network.GetAveragePing(Network.connections[0]));
             }
  
             if (GUILayout.Button("Disconnect"))
                 Network.Disconnect(200);
  
             ipaddress = Network.player.ipAddress;
             port = Network.player.port.ToString();
             GUILayout.Label("IP Address: " + ipaddress + ":" + port);
         }
     }
  
     void OnConnectedToServer()
     {
         foreach (GameObject go in FindObjectsOfType(typeof(GameObject)))
         {
             go.SendMessage("OnNetworkLoadedLevel", SendMessageOptions.DontRequireReceiver);
         }
     }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by HunterKrech · Mar 04, 2013 at 10:20 PM

You need to do quite a bit more code to get that functinality, try photon in the asset store.

Comment
Add comment · Show 2 · 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 jukenos · Mar 05, 2013 at 03:09 PM 0
Share

Okay, found it out, I forgot to add a script to spawn players. Thanks anyway.

avatar image Sericet1 · Mar 05, 2013 at 03:15 PM 0
Share

Thanks for asking this question!

avatar image
0

Answer by Riessu · May 08, 2013 at 04:09 PM

Are you use the function Network view ?! In Component => Miscellaneous => Network View.

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

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

12 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

Related Questions

How do I stop gameobjects from going through each other in the scene unity3d 1 Answer

Can't see the host of the server 1 Answer

How do you stop GameObjects from instantiating inside itself? 1 Answer

Unity networking tutorial? 6 Answers

Cant see Player moving Multiplayer 0 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