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
6
Question by Flynn · Jan 17, 2011 at 10:43 AM · networkingnetworkviewowner

Can NetworkView.owner be set?

Is it possible to transfer "ownership" of a network view to different players over time?

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

2 Replies

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

Answer by AKAssassin · Apr 14, 2011 at 05:26 PM

Kinda, but not in a very nice and direct way. From my understanding of Unity networking so far where ever you allocate the networkview.viedID is who the owner is.

For example is you instantiate an object that has a networkview on a client and then on that client says,

var id = Network.AllocateViewID();

obj.networkView.viedID = id;

then the client will be the networkView.owner, if you were to do that on the server, the server would be the owner.

So...

If you want to transfer ownership of an object it should be possible to do by allocating a new view id for the object on whoever you want to own the object and then assign the new id to the existing networkview, and the owner should now be changed.

But you would want to allocate the id first then send an rpc to all the other versions of the object on remote computers to change the id and then set the id. This way you don't break the viewid relationship across all computers running the game.

Hopefully this helps, I haven't actually tried doing this myself but if it is possible to do want you want to do, this is probably the most likely way of doing it.

Comment
Add comment · Show 5 · 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 Flynn · Apr 20, 2011 at 12:44 AM 0
Share

Thanks so much, that seems entirely accurate to me! :) I have not yet tested, but what you say Should work :D

avatar image JJC1138 · Apr 28, 2012 at 12:20 AM 1
Share

I've just tried this out this week and I can confirm that it does indeed work as expected. It brought up a couple of issues that I hadn't anticipated, though:

Firstly, changing the view ID messes up any buffered RPCs that were sent via the old ID. They still get sent, but a newly connecting client can't find the NetworkView and gives an error. I worked around that by having an extra NetworkView on my objects which I just use for RPCs, and that NetworkView is forever owned by the server and never gets its ID changed.

Secondly, if you send the RPCs to change IDs from a client, the server can sometimes send an additional state change from the old ID and clients receive that after they've changed to the new one, and that also gives an error on the clients when they can't find the NetworkView. The solution to that was to have the server change the IDs on its own NetworkViews, and then send another RPC to all the clients telling them to change their IDs. So in this setup the new owner sends a RPC$$anonymous$$ode.Server RPC with the new ID, and then the server does its own RPC$$anonymous$$ode.AllBuffered RPC to relay that to all the clients.

avatar image SentreStage · Mar 18, 2014 at 01:19 AM 0
Share

@JJC1138 - I wish I could upvote your comment! This was very useful information and gave me some insights on what I can do with my own networking code to transfer ownership in addition to what A$$anonymous$$Assassin posted in his answer. Thanks for sharing :)

avatar image SentreStage · Mar 18, 2014 at 01:21 AM 0
Share

I also feel I should mention that this same kind of technique can be used with Photon Unity Networking.

avatar image BrutalMax · May 31, 2014 at 12:30 PM 0
Share

@jjc1138 Could you show me your code? This thing is very important and I can't figure how to do it..

avatar image
0

Answer by Baumkuchen · Jul 30, 2016 at 04:34 PM

now there is a solution for photonengine: https://doc.photonengine.com/en/pun/current/tutorials/ownership-transfer

Or you simply call "photonView.RequestOwnership();" on that object witch owner should be changed

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Get NetworkPlayer from ViewID 1 Answer

Photon - How to name a player? 0 Answers

networkview.RPC not accessible in unity 5.4 1 Answer

Client can't serialize to client 1 Answer

Username not showing on other players head?? 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