Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 leonardo_try · Sep 24, 2011 at 08:31 PM · positionnetworkupdaterpccall

Can I use RPC calls in an Update function ?

Hey, i'm making a multiplayer game, and i got the logic working fine.

I used RPC calls for every thing, but i don't know if it's the right way to do it.

Can i use RPC calls sending the player position and lookDirection for all the other players in an Update function?

Or do i need to use some other way?

What i want to do is just send some informations of all players to all players in the update function (or some thing fast enough to pass position and rotation) in the same script, like an RPC call for every one passing these values.

Thanks in advance.

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 asafsitner · Sep 24, 2011 at 09:07 PM

You can send a RPC in Update(), but it's highly not recommended. Instead, have the networkView watch the script and use OnSerializeNetworkView() for state sychronization. (or, if you're just synchronizing rotation and position, have the networkView watch the Transform itself)

If you find the network send rate too slow, you can change the send intervals in the network settings through Edit -> Project Settings -> Network

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 syclamoth · Sep 24, 2011 at 10:45 PM 1
Share

I use RPC calls in the update loop for sending player actions- like jumping or attacking. Location and velocity information, though, should be synchronised with OnSerializeNetworkView().

avatar image asafsitner · Sep 25, 2011 at 05:55 AM 1
Share

@syclamoth yes, that is true. However, one needs to be very careful about the RPC buffer - sending, say 30 buffered RPCs per second (game @30 FPS) can cause huge problems, as some of them are almost guaranteed to be lost in the way, which will cause the buffer to swell with waiting RPCs. Could lead to very entertaining results. :)

avatar image leonardo_try · Sep 25, 2011 at 05:59 PM 0
Share

But do i need to use a networkView in every multiplayer character? or i can send all data in one networkView? Sorry, but i didn't understand how exactly OnSerializaNetworkView works, even with the docs :/

I have my fps character controller, and i need to pass the informations of this player to every one, that will update the 3rd person view of my character in their scene... there is something like, link a networkView to an other one?

avatar image asafsitner · Sep 25, 2011 at 06:44 PM 1
Share

Basically you need a networkView for everything that you want to sync over the network. I presume you'd have one as part if your player prefab, however, so you won't need to manually attach those.

In the OnSerializeNetworkView() method you make the check to see if you should read to the network or write from the network, so you know whether to update other players or your own.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rpc client issue 0 Answers

[2D] Get the position of an object outside the scope 2 Answers

Call an RPC to a specific client 1 Answer

How to change GameObject Material over Network! 0 Answers

Transfering vars to RPCs? 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