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
1
Question by jahames · Sep 27, 2017 at 06:28 AM · networkingphotonpun

Photon: I call PhotonNetwork.LeaveRoom() but my character doesn't leave

edit: this could be an issue in another script I'm using

I'm using PUN (free version).

After LeaveRoom() is called, all the players and player owned objects get destroyed as expected, but

OnLeftRoom() callback never gets called, and as a result, the player is stuck in the scene.

The script does something like this (and the class inherits from Photon.PunBehaviour):

 public void leaveRoom() {
     PhotonNetwork.LeaveRoom();
 }
 
 public void OnLeftRoom() {
     print("loading level");
     PhotonNetwork.LoadLevel("MainMenu");
 }

The bug only occurs when there's two players in the room.


update: it seems we attempt to connect to master after d/c but it never succeeds and photon does not throw any errors

https://imgur.com/a/NPIxT

This was the output from the NetworkingPeer.DebugReturn(...) member method.

 Resending: CMD(5 c#:255 r/u: 67/0 st/r#/rt:68313/1/78313). times out after: 56 sent: 68313 now: 68375 rtt/var: 24/8 last recv: 16
 UnityEngine.Debug:Log(Object)
 NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/StoreAssets/Photon/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1530)
 ExitGames.Client.Photon.EnetPeer:SendOutgoingCommands()
 ExitGames.Client.Photon.PhotonPeer:SendOutgoingCommands()
 PhotonHandler:Update() (at Assets/StoreAssets/Photon/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:177)


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 ChristianSimon · Sep 28, 2017 at 08:14 AM 1
Share

Hi,

connecting to the $$anonymous$$aster Server is correct when leaving the room, but OnLeftRoom should be called nevertheless. If you have enabled PhotonNetwork.autoJoinLobby, please check if OnJoinedLobby gets called and if you try to connect to a room in this callback. The logging from the screenshot tells you, that the client has joined a game (room) twice in a row, which is strange - this is EventCode 226.

Which PUN and which Unity version do you currently use?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jahames · Oct 02, 2017 at 01:36 AM

I found a work around that "solves" this. Instead of leaving the room then waiting for the OnLeftRoom callback, I call PhotonNetwork.Disconnect() then load level on the following line. This sometimes causes the player to load from in game -> main menu -> in game.

To fix this, I created a DontDestroyOnLoad object which will make the player load the appropriate scene and knows when the player should be in the main menu.

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 attishno1 · Oct 09, 2020 at 11:33 AM 0
Share

Please share the code. Thank you.

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

104 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

Related Questions

Photon pun problem on send and read request 0 Answers

OnConnectedToMaster() vs IsConnectedAndReady? 1 Answer

Player Won't Instantiate with Photon Unity Network [PUN] 0 Answers

How to list the rooms that are there [PUN] 2 Answers

Rigidbody2D jitter on collision. Photon Pun 2 sync issue? 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