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 vivalarosa · Oct 12, 2011 at 01:36 AM · multiplayernetworkrpconserializenetworkview

When to use OnSerializeNetworkView and RPC's

Hey,

I searched for some information on typical situations when to use RPC's over OnSerializeNetworkView but I couldn't track down any information.

I just wanted to know in what situations is it best to use an RPC over OnSerializeNetworkView and visa versa. In a tutorial im following at the moment he is using OnSerializeNetworkView for tracking player movement and then RPC's for things like pickups, but in another tutorial he was using RPC's for movement, is there a standard for which method to use for different situations?

Thanks :)

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

Answer by PatrikNyblad_SI · Oct 12, 2011 at 07:45 AM

To be honest, there is no right way and no wrong way. The different approaches have different strengths and weaknesses.

RPC

This will trigger a function on a device connected to the game, you can use the call to send to a specific player, everyone but your self or everyone. This call can be triggered no matter if the Networkview is your own or if it belongs to one of your other players. One good thing about this is that it will not use any traffic unless you actually call a method with RPC but you should stay away from using it every frame. Another good thing about RPC is that you always get the calls in the right order but if you make too many calls your whole game will be delayed due to this in a slower network (or with many players).

I personally use RPC when letting other users interact with a rotating sphere at the same time as myself in my game.

The most obvious time to use RPC is when you are setting states in your game and applying damage or health. Those one time calls should always be performed with an RPC call. The reason is simple, you dont want unnecessary traffic in your game to steal bandwidth. If you would have done this with the Serialize method the values would only be one way (from owner of the networkview to the other clients) and you would have this sent each network tick (standard 15 ticks per second).

Serialized

This has the benefit of being synced at a specific rate and you can set if it is going to wait for previous packages or not. The documentation does a good job of describing the different modes. http://unity3d.com/support/documentation/Components/net-StateSynchronization.html

The serialized would be great for something like an enemy that needs to transfer its position to the other network players. I use this for a zombie type of enemy (a different game then the sphere) right now and i decided to sync a script that just handles the movement over network. The only thing I need to sync is the position and rotation of the enemy at a set rate (since it will be changing all the time I prefer the Unreliable mode). My script then Lerps between the current position and the new position and rotation that arrive from the networkview.


Im sure there are more people out there who have more tips and tricks that they use for their specific games and this is just my experience and advice. If you have any more specific scenario I could give you my opinion for that also.

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 vivalarosa · Oct 12, 2011 at 02:06 PM 0
Share

Thanks so much for the detailed response and link Patrik, it's quite hard to find good information on this topic :). I'm new to the networking scene so every piece of information is invaluable :). Thanks again, it's very much appreciated.

avatar image yeagz7 · Feb 26, 2013 at 04:02 AM 0
Share

I know this was a while ago but do you still know the name or link of that tutorial? Thank you.

avatar image Jeremy Hindle · Feb 26, 2013 at 04:09 AM 0
Share

solid answer

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

When connected to a server, can other players access my static variables and/or public variables? 2 Answers

Photon Networking: RPC call doesn't work over other clients 0 Answers

Sending info to/from different networkViews 1 Answer

Can you tell OnSerializeNetworkView who the owner is? 3 Answers

RPC Parameter Optimization 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