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 Madswint · Jan 13, 2014 at 02:05 PM · networkingdisconnect

Why dont this script work?

Basicly I'm trying to make it so if the server host disconnects, ALL player objects gets wiped.

 function OnDisconnectedFromServer (player: NetworkPlayer) {
         Debug.Log("Disconnected from server: " + player);
         Network.RemoveRPCs(player);
         Network.DestroyPlayerObjects(player);
 
 }

This should work shouldn't it!?

Gives me error : Script error: OnDisconnectedFromServer This message parameter has to be of type: The message will be ignored.

I just dont understand it

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

Answer by MrCranky · Jan 13, 2014 at 03:16 PM

OnDisconnectedFromServer doesn't take a network player as an argument. The parameter should be a NetworkDisconnection object, which presumably will give the reason why you were disconnected. You will have to figure out which network player was disconnected some other way.

Comment
Add comment · Show 4 · 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 Madswint · Jan 13, 2014 at 03:27 PM 0
Share

I have made it so if a player disconnects, so does his stuff (player model etc), but I'm trying to make it so when the host leaves or shuts down server, all player objects from all players is removed. Any idea how to?

avatar image MrCranky · Jan 13, 2014 at 03:41 PM 0
Share

No idea, there's only a tiny fraction of your code provided.

It seems like a non-issue though. The host leaving isn't a special case of OnPlayerDisconnected, it's going to kill the server, surely? If the host leaves or disconnects, then everyone else will get the disconnection notice, because the server has gone away.

There are only two real events: either you have disconnected, or someone else has and you're still connected. If someone else has disconnected, you clean up their objects. I'm presu$$anonymous$$g you're already doing that on OnPlayerDisconnected. If you have been disconnected, then it doesn't matter if it was because the host died or because you got kicked, either way you should be cleaning up everyone else's objects as well as your own.

avatar image Madswint · Jan 13, 2014 at 03:47 PM 0
Share

Right now, only if a player disconnects his stuff gets cleaned, but if a host leaves and the connections stops, it's as if they were still in game, other than they cant see other players moving ofcourse. I'm trying to make it do the same thing as it does when player disconnects, to when a host closes server, basicly delete their player model.

avatar image MrCranky · Jan 13, 2014 at 04:02 PM 0
Share

Right, so what's stopping you from doing that? If you get OnDisconnectedFromServer, then the game is done and you need to clean up. Put that method on whatever component manages your player model and every other player model, and do the cleanup there. You've given no indication as to how your code is structured, so we can't tell you where you should put the method or what it should do.

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

19 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

Related Questions

Errors shown when server tries to send ClientRpc to a client who just disconnects 0 Answers

Destroy its own instantiated objects when leaving server 1 Answer

[UNET] How to handle disconnection? 1 Answer

Multiplayer Game Disconnects 1 Answer

Could not connect to a server that was full 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