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 zak666 · May 06, 2016 at 12:53 AM · networkingphotonscript errorconnection

error spawning player says I'm not connected when photon connects and puts me in a room

ok so i connect yup join lobby yup join room yup. I'm in me game, tho when i go to spawn a player it gives me an error I'm not connected? (these are both on me missioncontroll empty game object yes it has network view assigned to it.)

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 public class Missioncontroll : Photon.MonoBehaviour {
 
     const string VERSION =  "0.1";
     public string roomName = "GameRoom";
     public float Timer = 500f; // amount of time before game with bots.
     private bool inGame = false;
     public NetworkView nView;
     public static int IamPlayer = 0;
     public int Maptoload = 0;
 
     public GameObject ToggleOnOff;
     public GameObject ToggleOnOff2;
 
 
     //score controllers
     public GameObject Player1;
     public GameObject Player2;
     public GameObject Player3;
     public GameObject Player4;
     public GameObject Player5;
 
     //number of players in room (ICON)
     public GameObject GameObjectPlayerIcon1;
     public GameObject GameObjectPlayerIcon2;
     public GameObject GameObjectPlayerIcon3;
     public GameObject GameObjectPlayerIcon4;
     public GameObject GameObjectPlayerIcon5;
 
     public GameObject map1;
 
     //TimerDisplay
     public Text Timertext;
 
     //------------------------------------------------------------------------------------------------------------
     void Awake() {
         Network.minimumAllocatableViewIDs = 500;
 
     }
 
     void Start(){
         nView = GetComponent<NetworkView>();
 
         Connect ();
     }
 
     //------------------------------------------------------------------------------------------------------------
 
 
     void Connect(){
         PhotonNetwork.ConnectUsingSettings (VERSION);
 
         }
 
     //------------------------------------------------------------------------------------------------------------
 
 
 
     //-------------------------------------------------------------------------------------------------------------
 
 
     void OnJoinedLobby () {
         Debug.Log ("Joined Lobby");
         RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 5 };
         PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
     }
 
     //--------------------------------------------------------------------------------------------------------------
     void OnPhotonRandomJoinFailed(){
         Debug.Log ("Failed Join");
         PhotonNetwork.CreateRoom (null);
     }
 
     //--------------------------------------------------------------------------------------------------------------
     void OnJoinedRoom() {
         
 
         Debug.Log ("Joined Room");
 
         BotGameController.NumberofPlayers -= 1; //(add a player to the player counter)
 
 
 
         if (PhotonNetwork.countOfPlayers == 0){ 
             Player1.SetActive (true);
 
             GameObjectPlayerIcon1.SetActive(true);
         }
 
 
         if (PhotonNetwork.countOfPlayers == 1){ 
             Player1.SetActive (true);
         
                 IamPlayer = 1;
         }
 
         if (PhotonNetwork.countOfPlayers == 2){ 
             Player2.SetActive (true);
             NetworkViewID viewID = Network.AllocateViewID ();
             nView.RPC ("Haveplayer2", RPCMode.AllBuffered, viewID, transform.position);
             IamPlayer = 2;
 
 
         }
 
         if (PhotonNetwork.countOfPlayers == 3){ 
             Player3.SetActive (true);
             NetworkViewID viewID = Network.AllocateViewID ();
             nView.RPC ("Haveplayer3", RPCMode.AllBuffered, viewID, transform.position);
 
             IamPlayer = 3;
 
         }
 
         if (PhotonNetwork.countOfPlayers == 4){ 
             Player4.SetActive (true);
             NetworkViewID viewID = Network.AllocateViewID ();
             nView.RPC ("Haveplayer4", RPCMode.AllBuffered, viewID, transform.position);
 
             IamPlayer = 4;
 
         }
 
         if (PhotonNetwork.countOfPlayers == 5){ 
             Player5.SetActive (true);
             NetworkViewID viewID = Network.AllocateViewID ();
             nView.RPC ("Haveplayer5", RPCMode.AllBuffered, viewID, transform.position);
             IamPlayer = 5;
 
         }
     }
 
     //every time a player joins tell others in the room to set icons.
     //------------------------------------------------------------------------------------------------------------
 
     [PunRPC]
     void Haveplayer1(){
         GameObjectPlayerIcon1.SetActive(true);
 
     }
     //------------------------------------------------------------------------------------------------------------
     [PunRPC]
     void Haveplayer2(){
         GameObjectPlayerIcon2.SetActive(true);
         GameObjectPlayerIcon2.SetActive(true);
 
     }
     //------------------------------------------------------------------------------------------------------------
     [PunRPC]
     void Haveplayer3(){
     GameObjectPlayerIcon1.SetActive(true);
     GameObjectPlayerIcon2.SetActive(true);
     GameObjectPlayerIcon3.SetActive(true);
     }
 
     [PunRPC]
     void Haveplayer4(){
         GameObjectPlayerIcon1.SetActive(true);
         GameObjectPlayerIcon2.SetActive(true);
         GameObjectPlayerIcon3.SetActive(true);
         GameObjectPlayerIcon4.SetActive(true);
 
     }
 
 
     [PunRPC]
     void Haveplayer5(){
         GameObjectPlayerIcon1.SetActive(true);
         GameObjectPlayerIcon2.SetActive(true);
         GameObjectPlayerIcon3.SetActive(true);
         GameObjectPlayerIcon4.SetActive(true);
         GameObjectPlayerIcon5.SetActive(true);
     }
 
     //------------------------------------------------------------------------------------------------------------
 
 
     void mapselectselect (){
         //randomrange (mapselect)  (consistent with all players so they all end up in same map.)
         map1.SetActive(true);
         ToggleOnOff.SetActive (false);
         ToggleOnOff2.SetActive (true);
 
     }
 
 
     //------------------------------------------------------------------------------------------------------------
 
 
     void LateUpdate (){
 
         //loadmap automaticly after timer regadless of player count.
         Timer -= 1;
         if(Timer <1){
             mapselectselect();
         }
 
         Timertext.text = "" + Timer.ToString();
 
     }
 
     //------------------------------------------------------------------------------------------------------------
 
     //------------------------------------------------------------------------------------------------------------
 
     void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
         {
             if (stream.isWriting) {
                 // We own this player: send the others our data
                 stream.SendNext (inGame);
             } else {
                 // Network player, receive data
                 this.inGame = (bool)stream.ReceiveNext ();
 
             }
 
 
         }
     }
 }    
    //------------------------------------------------------------------------------------------------------------









 public class StarfighterSelet : MonoBehaviour {
  
  
      public GameObject Fighter01;    
      public GameObject Fighter02;
  
      public GameObject Camera1;
      public GameObject ShipSelectGUI;
      public GameObject GameGUI;
  
      public Transform SpawnPlayer;
  
  
      public void Fighter01Select () {
          ShipSelectGUI.SetActive (false);
          GameGUI.SetActive (true);
          Network.Instantiate(Fighter01, SpawnPlayer.position, SpawnPlayer.rotation, 1);
  
  
      }
  
  
      public void Fighter02Select () {
          ShipSelectGUI.SetActive (false);
          GameGUI.SetActive (true);
          Network.Instantiate(Fighter02, SpawnPlayer.position, SpawnPlayer.rotation, 1);
  
      }
  }
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

60 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

Related Questions

Failed Network.Instantiate because we are not connected. (when logs show i connect and joined room.) 0 Answers

Client Disconnect with message “Peer Created” - PUN 0 Answers

PhotonNetwork.Instantiate is not "buffered" 0 Answers

[Edited]How To establish a mmo game By using Bluetooth 1 Answer

Photon Networking: LocalScale transform doesn't work 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