• 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 arsh24 · Mar 27, 2022 at 02:02 PM · scenedestroyphotonscene-loadingscene-switching

Client player cannot see MasterClient player after scene change

I am making a multiplayer game in w$$anonymous$$ch both players can switch scenes separately. My problem is that after Player1 goes from scene 1 to scene 2, everyt$$anonymous$$ng 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 t$$anonymous$$s 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. T$$anonymous$$s is why photon view IDs are changed after scene change, but what is the solution to t$$anonymous$$s problem? T$$anonymous$$s 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, w$$anonymous$$le Player1 can see Player2.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

169 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 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 switch scenes with two players using Photon? 1 Answer

How to disable Dont destroy on load 0 Answers

How Do I Link Different Scenes? 4 Answers

Change Scene keeping Character and GUI Canvas 1 Answer

AsyncOperation "studders" next scene load and Scene speed problem 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