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 Afterthought · Aug 10, 2013 at 05:13 PM · networkviewstate synchronization

Problems changing NetworkStateSynchronization at runtime.

In my game the server creates starships for new clients when they join the server. Weapons on the ships are child objects that are instantiated via RPC calls that also provide a server-allocated viewID. One type of weapon is a drone that separates from the ship when launched (by removing it's parent, etc, via another RPC call).

Currently, the state synchronization for the drone prefab is set to unreliable in the inspector so that the drone can move on it's own after separation. I hate doing this, though, as it seems dumb to have a bunch of child objects receive state updates when they don't need to.

I want to set the state synchronization via the RPC call to separate the drone from the ship, but all attempts at setting this at runtime have failed. This is really no surprise as the script reference page for state synchronization says "Do not change state reliability on the fly after state synchronization has already happened". However, I feel like there has to be some way to get around this...

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
0

Answer by Jamora · Aug 10, 2013 at 05:57 PM

You don't actually have to serialize anything when OnSerializeNetworkView is called. You could do a quick fix with something like:

 void OnSerializeNetworkView( /*parameters*/){
    if(separated){
       /*Do serialization*/
    }
 }

This way nothing should be sent over the network and the only overhead is of calling the function and checking the bool.

Because of my dislike for bool flag checking, I would instead have all the separatable ships attached to the mothership without a network view. Whenever one separates, I'd do a Network.Instantiate and send an RPC to everyone to disable the stationary one.

Comment
Add comment · Show 3 · 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 Afterthought · Aug 10, 2013 at 07:15 PM 0
Share

I'm not quite following you. I'm not currently using OnSerializeNetworkView since the state synchronization seems to handle transform serialization on it's own.

Are you saying that if I add an OnSerializeNetworkView function then this (automatic transform serialization) will not occur and I'll need to serialize that information manually?

avatar image Jamora · Aug 10, 2013 at 07:33 PM 0
Share

If you're observing the gameobjet's transform with your networkView, then Unity will do the state syncing for you.

You can do a custom serialization by creating a script and setting that as the observed component of the networkView. (Drag and drop the title of the script into the observed slot of the networkView.) OnSerializeNetworkView will then be called sendRate times per second in that script.

avatar image Afterthought · Aug 11, 2013 at 06:22 AM 0
Share

Thanks Jamora, your answer prompted me to try something else that solved the issue. Posting answer below:

avatar image
0
Wiki

Answer by Afterthought · Aug 11, 2013 at 06:40 AM

The issue was solved (I think) by NOT setting the observed property of the networkView to the drone's transform by default. Instead, I set it to a random script on the object to keep it from sending state updates until separation. At separation I set the observed property to the transform and all is well.

Note that I tried setting the default observed object to None, but this results in some warnings on the client upon connecting to the server about state updates for observed objects that do not exist. Setting it to a random script on the object doesn't cause this warning to appear.

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

15 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

Related Questions

Supress initial OnSerializeNetworkView state update 0 Answers

Animation and Reliable Delta Compression State Synchronization 1 Answer

Sync Animations through Network (Mecanim) 0 Answers

Can NetworkView sync 2 different scripts? 1 Answer

NetworkView Control 2 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