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 sdgd · Aug 23, 2013 at 07:07 PM · c#networkingdocumentationconfused

Networking Destroy Player's RPC function uhm WHAT?

ok the Q may be seem trivial to you but I just started learning networking I don't understand aloot.

I was starting to trying to figure out how to give each player a specific class when he logs in and so and how to destroy that class he "owns" on server and stuff like that, ... but I've run in to the documentation witch turned my head around (like I understood gravity but now I don't any longer), ...


Been reading this 2 manuals:

  • Network.OnDisconnectedFromServer

  • Network.OnPlayerDisconnected

    using UnityEngine; using System.Collections;

    public class Example : MonoBehaviour { void OnPlayerDisconnected(NetworkPlayer player) { Debug.Log("Clean up after player " + player); Network.RemoveRPCs(player); Network.DestroyPlayerObjects(player); } }

well I've figure out I'll probably need OnPlayerDisconnected since I was searching for:

 [RPC]
     void SomeFunction (NetworkMessageInfo Info){
     }

so I would somehow figure out how to determen witch class to destroy, ...

BUT as far as I knew the:

  • client was sending RPC functions to server

  • server was verifying if server knows that exact RPC functions and executed them

but now I'm reading:

 Network.RemoveRPCs(player);

so what does it do?:

  • connects back to client and deletes the functions I've wrote on client? kinda highly unlikely, ...

  • Deletes the RPC functions on the server to witch server has access since client has disconnected and deletes them so other clients cannot use them any longer?

  • OR even more strange thing to reverse the process and calculates the WHOLE thing how else would physics go if that player wouldn't do any RPC calls, ...

like the title says uhm WHAT?, ... it puts all the logic I understand on the head, ...

the second thing if there's a function call:

 Network.DestroyPlayerObjects(player);

how do I tell that function what objects ARE the objects this particular client has? or will it delete everything this client has touched meaning half of my HDD with him, ...

I'm sorry this documentation totally confuses me and puts all my logic on the head, .. can some one turn it back on please, ... OR my head will start to hurt, ...

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
1
Best Answer

Answer by Jamora · Aug 23, 2013 at 10:12 PM

No one truly knows how Unity's networking works; I answered this question with how I think Unity determines object ownership and not everyone agreed with me...

Basically, I believe the server keeps track of all connected players, what objects they've created and what RPCs they've sent. (This is also the reason everyone sees the server as the owner of all network.instantiated objects, unless the player himself instantiated it.)

I would imagine that the server just keeps a data structure of all RPCs and Objects instantiated by everyone. Calling Network.RemoveRPCs(player); just clears all buffered RPCs from that data structure so the server doesn't send them to any newly connected player. Conversely, calling Network.DestroyPlayerObjects(player); just destroys the GameObjects that are Network.Instantiated by player on each client. So basically the server just does something similar to networkView.SendRPC("Destory",RPCMode.All,listOfObjects);

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 sdgd · Aug 24, 2013 at 09:50 AM 0
Share

in that post you said:

Though you can set it up as a p2p (server) so how do you do that?


thanks, ...

this is pretty informative :)

before I was instantiating objects with RPC function like:

 [RPC]
 void something (int i){
         if (i == 1){
             Instantiate(SomeGameObject);
         }
     }
 

I still think this way is more efficient and was thinking how to keep track so new player does not connect to this same GO that I would verify with string username AND if disconnected I would delete the class he was using it but store the values.

and thanks this gives me a bit of a jump since I didn't know I could call network.instantiate object will dig more in those lines.

avatar image Jamora · Aug 24, 2013 at 02:00 PM 1
Share

I said p2p, but I actually meant a sort of a hybrid. You can set a semi-p2p network by storing each player's NetworkPlayer on each client, so that each player knows every other player in the game. This can be achieved by the server sending an RPC to everyone to add a new player in OnPlayerConnected.

Once every player knows each other NetworkPlayer, they can use the version of RPC with the NetworkPlayer parameter to send data directly to that player.

This won't be true p2p in the sense that if the server disconnects, every client will be disconnected as well.

As for your question of keeping track of connections, it sounds like a topic for a new question. Do remember to put in more information on what you're trying to achieve, because currently I don't understand the question.

avatar image sdgd · Aug 24, 2013 at 11:26 PM 0
Share

to send data directly to that player?

that's exactly what I was looking for I need that to lower bandwidth.

can you provide the code please.

what I want to achieve is only learning for now. basically when I write code I never know what my goal is but I build like what seems best at that point and I write forward.

and currently I'm trying to make tracking each client when it logs in and if connection breakes and get's back in that he can still play but if off connected for more than 5 $$anonymous$$ he's loged out. BUT that no other client cannot replace him when he's disconnected, ... maybe I could maybe I cant , ... I'll play with this tomorrow.

that's why it's fun program$$anonymous$$g for me and that's why I haven't stopped at first step towards big $$anonymous$$$$anonymous$$ORPG game or what ever it my be the result.

I'll be playing with this more tomorrow, yes that's way out of topic thanks for putting the logic back on and if tomorrow I'll reach another road block I'll ask a question.

avatar image Bunny83 · Aug 24, 2013 at 11:50 PM 1
Share

You got that wrong. It's just a kind of p2p. All data will always go through the server, so that wouldn't lower the bandwidth at all. In the end it will always be a client - server - model. If a client has the networkplayer object of another client he can send an RPC to this client only, but it will still go through the server since that's the only connection a client has.

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

17 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

UNET Health isn't syncing 1 Answer

Making a list of distinct IPs broadcasting UDP 0 Answers

C# How to have a gun select 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