Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 gabepupr · Nov 15, 2013 at 12:20 PM · detectdisconnectmaster server

How to detect when player disconnects from master server?

Hello,

I am currently almost done with a Capstone project I have been working on for College. I had not had the need to ask any questions thats to this community and various tutorials; that is until now.

My game is a driving game that simulates how the roads/driving are/is in Puerto Rico. One part of this project is to create multiplayer, which we decided to use the Master Server provided by Unity.

I have the networkViews running and I can get players to join and interact the problem is I would like to detect for the Network.isServer side when a player has disconnected, so that i can reduce the number of players and Destroy that gameObject.

So my question is this, how do I detect from the server side, that a player has disconnected and destroy the object? I have 1 week left to finish and this would be a nice feature to have.

Thanks in advance, I really need your help if you can help me. I would not ask if I did not :(

P.S. The Server side is another player A.K.A. the Host

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

1 Reply

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

Answer by gajdot · Nov 15, 2013 at 12:34 PM

There is a function called OnPlayerDisconnected which is called every time when a player disconnects from the server, maybe you are looking for that one. I used a code like this:

 void OnPlayerDisconnected(NetworkPlayer networkPlayer)
     {
         // When the player disconnects remove them across the network, so nobody can see them
         Network.RemoveRPCs(networkPlayer);
         Network.DestroyPlayerObjects(networkPlayer);
     }
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 gabepupr · Nov 15, 2013 at 01:13 PM 0
Share

Thanks alot! this is what I was looking for; however I can not believe how simple it is O_O. you are a life saver :D

avatar image gajdot · Nov 15, 2013 at 01:31 PM 0
Share

You're welcome :)

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

18 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

Related Questions

Multiple Cars not working 1 Answer

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer

Network disconnect player 1 Answer

Unhandled message error when registering host 1 Answer

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 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