• 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 /
  • Help Room /
avatar image
0
Question by sniperguy124 · Nov 24, 2016 at 03:18 PM · errornetworkinginstantiatemultiplayerphoton

Unity [PUN] New Instantiated players cannot see previously instantiated players

Hello, i have recently worked on a game, but now i have this error where a new instantiated player cannot see previously instantiated players, but previously instantiated players can see newly instantiated players. There are also no error messages or warning messages in the console, though i got some previously that just magically dissapeared. It was something like failed to (something) on serilization with id 1001 ignore this if you are leaving a server.

I have 2 scenes, one called LobbyMenu and one called Game.

This script is mounted in the Game scene: using UnityEngine; using System.Collections; using UnityEngine.SceneManagement;

public class GameManager : Photon.MonoBehaviour {

 public string playerPrefabName = "FPSController";
 public Transform SpawnPoint;

 void Start()
 {
     if (PlayerManager.LocalPlayerInstance == null)
     {
         GameObject pl = PhotonNetwork.Instantiate(playerPrefabName, SpawnPoint.position, SpawnPoint.rotation, 0) as GameObject;
     }
 }

 public void OnLeftRoom()
 {
     SceneManager.LoadScene(0);
 }

 public void LeaveRoom()
 {
     PhotonNetwork.LeaveRoom();
 }
 

}

This second script is mounted in the LobbyMenu scene:

using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;

public class Launcher : Photon.MonoBehaviour { const string VERSION = "1"; public string roomName = "iskrem"; public string playerName; public Text input; public Text nameInput; public GameObject connect; public GameObject roomInfo; public GameObject NameInput;

 void Start()
 {
     PhotonNetwork.ConnectUsingSettings(VERSION);
     roomInfo.SetActive(false);
     NameInput.SetActive(false);
     connect.SetActive(true);
 }

 void OnGUI()
 {
     GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
 }


 public void ChangeRoom(int value)
 {
     if(value == 0)
     {
         roomName = "server 1";
     }
     else
     {
         value = 0;
     }
 }

 public void RoomSelect()
 {
     OnJoinedLobby();
 }

 public void ConnectToRoom()
 {
     roomName = input.text;
     OnJoinedLobby();
 }

 public void Spawn()
 {
     PhotonNetwork.LoadLevel(1);
 }

 public void NameSelected()
 {
     playerName = nameInput.text;
     roomInfo.SetActive(true);
     NameInput.SetActive(false);
 }

 void OnJoinedLobby()
 {
     RoomOptions roomOptions = new RoomOptions() { IsVisible = false, MaxPlayers = 4 };
     PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
     print("Successfully Joined or Created" + roomName);
 }

 void OnJoinedRoom()
 {
     NameInput.SetActive(true);
     connect.SetActive(false);
 }

}

This last script is mounted on my player: using UnityEngine; using System.Collections; using UnityStandardAssets.Characters.FirstPerson;

public class PlayerManager : Photon.MonoBehaviour {

 public GameObject Camera;
 public static GameObject LocalPlayerInstance;

 public void Awake()
 {
     // #Important
     // used in GameManager.cs: we keep track of the localPlayer instance to prevent instanciation when levels are synchronized
     if (photonView.isMine)
     {
         LocalPlayerInstance = gameObject;
     }

     // #Critical
     // we flag as don't destroy on load so that instance survives level synchronization, thus giving a seamless experience when levels load.
     DontDestroyOnLoad(gameObject);
 }

 void Start ()
 {
     if (!photonView.isMine)
     {
         Camera.SetActive(false);
         GetComponent<RigidbodyFirstPersonController>().enabled = false;
     }
 }

}

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

147 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 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 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 to make an enemy who will walk behind all players if they go into the radius? Finding by the tag Player. [PUN]. 1 Answer

Unity Photon doesn't Spawn Player 0 Answers

'Spawn scene object not found 1' Error 3 Answers

[PUN] Photon Custom Properties - All Clients Fails to Change the Value 1 Answer

Photon Voice chat and Speech to text plugin not working together 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges