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 /
This question was closed Jun 17, 2019 at 12:44 AM by PRDarkSide for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by PRDarkSide · May 29, 2019 at 12:07 PM · 2dcharacterphotondisconnect

[PUN] Leaving room won't delete player on LeftRoom()

So when the player clicks the "Disconnect" button it loads them into the main menu but leaves their character behind, and leaves a random player with the player's character to control at the same time. Is there anyway to delete the disconnecting player's character so this doesn't happen.

Comment
Add comment · Show 2
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 Captain_Pineapple · Jun 01, 2019 at 01:02 PM 0
Share

Please add what acutally happens when you press that button. How do you load the next scene? What version of pun are you using?

avatar image PRDarkSide Captain_Pineapple · Jun 16, 2019 at 03:17 AM 0
Share

Sorry work got in the way for a bit, but to answer your question when I press the disconnect button I call a function called DisconnectPlayer() and in this it hits a StartCoroutine(DisconnectAndLoad()); and this coroutine has photonnetwork.leaveroom(); and I have a while loop that stops and waits till PhotonNetwork.InRoom returns null and then I use the scene manager to load my menu screen. I should also be on the latest version of PUN.

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by PRDarkSide · Jun 17, 2019 at 12:41 AM

OK, GOOD NEWS! I have figured it out. So in one of my room scripts I had a OnPlayerLeaveRoom which had a Player parameter called otherPlayer. I used this to utilize the PhotonNetwork.DestoryPlayerObjects class and used otherPlayer as the parameter for that and it did the trick. Thanks to all that helped.

Comment
Add comment · Show 2 · 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 PRDarkSide · Jun 17, 2019 at 12:43 AM 0
Share

And this does sync it across all clients even when the master client disconnects and the host is migrated.

avatar image afakul · Aug 04, 2021 at 09:58 AM 0
Share

it doesnot work ,

avatar image
0

Answer by NoCandyIncluded · Jun 01, 2019 at 03:11 PM

When the button is pressed, call the Destroy method or SetActive to false. For example.

 Destroy(GameObject.Find("[NAME OF GAMEOBJECT]"));


or

  GameObject.Find("[NAME OF GAMEOBJECT]").SetActive(false);





Comment
Add comment · Show 2 · 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 Captain_Pineapple · Jun 01, 2019 at 05:13 PM 1
Share

This will not work for his issue. When using Photon PUN destroying or setting inactive will not sync over the network but rather throw exceptions.

avatar image NoCandyIncluded · Jun 01, 2019 at 05:41 PM 0
Share

Oh, I didn't realize this, my bad. Thanks for pointing that out.

Follow this Question

Answers Answers and Comments

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

Related Questions

How can I add a acharacter to a 2d game? 1 Answer

2d Character movement script (unity 4,3) 2 Answers

Is possible to spawn 2d image in photon networking ? 1 Answer

cant jump in 2d? 4 Answers

Player respawn not working like intended 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