- Home /
Client player cannot see MasterClient player after scene change
I am making a multiplayer game in which both players can switch scenes separately. My problem is that after Player1 goes from scene 1 to scene 2, everything is fine. However, when Player2 goes from scene 1 to scene 2, he cannot see Player1 (who is already in the scene). In Player1's window, I can see Player2 but an error is thrown: "EV Destroy Failed. Could not find PhotonView Error" In a sense, only MasterClient (Player1 in this case) can see the other player, but I don't know how to resolve the issue. In scene 1, both players can see each other, but not after they change their scene. Here is the code on the collider object where scene will be changed:
public class ChangeScene : MonoBehaviour
{
[SerializeField]
public string scene;
private void OnTriggerEnter(Collider other)
{
PhotonView phView = other.gameObject.GetComponent<PhotonView>();
if (phView.IsMine)
{
Debug.Log("Before destroy photon View = " + other.gameObject.GetPhotonView());
PhotonNetwork.AutomaticallySyncScene = false;
PhotonNetwork.Destroy(phView);
PhotonNetwork.LoadLevel(scene);
Debug.Log("SCENE CHANGED!");
Debug.Log("SCENE CHANGE NO OF PLAYERS IN ROOM: " + PhotonNetwork.CurrentRoom.PlayerCount);
}
}
}
The photon view also has to be destroyed before changing scene, otherwise the player still remains in the scene and goes to the other scene as well. This is why photon view IDs are changed after scene change, but what is the solution to this problem? This is the method I use to instantiate players in the scene:
void SpawnPlayer()
{ GameObject player = PhotonNetwork.Instantiate(playerPrefab.name, spawnPoint.position, spawnPoint.rotation);
}
UPDATE: Even if I don't destroy Photon View, Player2 still cannot see Player1 in scene 2, while Player1 can see Player2.
Your answer
Follow this Question
Related Questions
How to switch scenes with two players using Photon? 1 Answer
How Do I Link Different Scenes? 4 Answers
Change Scene keeping Character and GUI Canvas 1 Answer
Can't find game object / script after scene re-enter 1 Answer
Scene Loading Issue. 0 Answers