Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Miaw666 · 2 days ago · multiplayerphotonmultiplayer-networking

Photon connections problems caused by a script?

This is the code that is creating the problem (more specifically it's the code inside the "foreach"):

     void Start()
     {
         photonView = GetComponent<PhotonView>();
         if (photonView.IsMine)
         {
             allGameObjects = FindObjectsOfType(typeof(GameObject));
             foreach (GameObject objct in allGameObjects)
             {
                 if (objct.tag != LayerMask.LayerToName(gameObject.layer) && objct.tag != "IgnoreDeletion")
                 {
                     Destroy(objct);
                 }
             }
         }
     }

The problem is that after I build the game and run it twice the second player can't connect to the first player that created the room and gets a "no such room exists". That is the case, but I tried the same built game a few times and sometimes it works; I say this because I assume it's something that has to do with performance or not allowing enough time or something like that, hopefully it can help you know what the exact problem is.

Comment
Add comment · Show 1
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 Miaw666 · 2 days ago 0
Share

What I want to do basically is delete everything in the scene for player1 that does not have to do with player1, and so on for every other player.

Player1 should only see player1 world AND the other players. Player2 should only see player2 world AND the other players.

I realize this is a bad way to make this but I have no clue how else it's supposed to be done.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GetLitGames · 2 days ago

I mean that code probably destroys almost all the objects in the game, if not all of them.. What are you trying to do? First off, you shouldn't destroy objects unless you created them in multiplayer. Second, try using GameObject.FindObjectsWithTag("tag") - your logic is wide open and it reads like it will destroy almost everything.. which I doubt is your intention.

Comment
Add comment · Show 1 · 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 Miaw666 · 2 days ago 0
Share

The logic of the code does work; It destroys everything that does NOT have the same tag as the players layer (basically every object that does not belong in the players scene) and and leaves everything tagged "IgnoreDeletion".

I don't understand why this creates connection problems with photon though...?

What do you mean with "you shouldn't destroy objects unless you created them in multiplayer" tho?

avatar image
0

Answer by viarsn · 2 days ago

My understanding of Photon is that each client loads the scene as if it was single player. Objects with photon views are synced (depends on which parts of that object you're syncing also, i.e., transforms). If player two joins the room, that doesn't mean that player one is going to see new items pop up and duplicated. Unless both clients are calling PhotonNetwork.Instantiate or RPC instantiations. Something is going confusingly wrong if when player two joins, his world is being duplicated on top of player ones world. Use PhotonNetwork.Destroy on photonviews if you want both clients to destroy the same object. If you do regular Destroy, only the player who called it will show it as destroyed.

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

236 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Networking: Keep room alive without active players 0 Answers

Oculus Quest Photon Network bugs connecting players 2 Answers

How to connect to our own dedicated server using photon networking in unity?(Self-hosted) 0 Answers

Photon Pun 2 "using photon.pun" not working. 8 Answers

Is it possible to select one scene out of given option and make it public for others to join ? 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