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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
-2
Question by DryTear · Dec 26, 2013 at 01:36 AM · networkrpc

[Solved]Send rate of rpc is slow even if Network.sendRate = 15;

 void Start ()
 {
         InvokeRepeating ("Rate", 0, 2.5f);
 }
 void Rate()
 {
     Network.sendRate = 15;
 }

Ive tried that, it still didnt work, i have this script that sends an rpc telling where a player is everytime the Vector3 position is different from last position. And it does sends, but instead it sends the rpc twice per second when testing on 2 pc's even on same machine. Using a Mac OS X maverick with U3D free version

Heres the MovementUpdate.cs ( similar to how M2H does it )

 using UnityEngine;
 using System.Collections;
 
 public class MovementUpdate : MonoBehaviour
 {    
     private Vector3 lastPosition;
     
     private Quaternion lastRotation;
     
     private Transform myTransform;
 
     void Start () 
     {
         if(networkView.isMine == true)
         {
             myTransform = transform;
             
             networkView.RPC("Sync", RPCMode.Others,myTransform.position, myTransform.rotation);
         }
         
         else
         {
             enabled = false;    
         }
     }
 
     void OnPlayerConnected(NetworkPlayer player)
     {
         networkView.RPC("Sync", player,myTransform.position, myTransform.rotation);
     }
 
     void Update () 
     {
         if(Vector3.Distance(myTransform.position, lastPosition) >= 0.1f)
         {
             lastPosition = myTransform.position;
             
             networkView.RPC("Sync", RPCMode.Others, myTransform.position, myTransform.rotation);
         }
         
         
         if(Quaternion.Angle(myTransform.rotation, lastRotation) >= 1)
         {
             lastRotation = myTransform.rotation;
             
             networkView.RPC("Sync", RPCMode.Others,myTransform.position, myTransform.rotation);
         }
     }
     
     
     [RPC]
     void Sync (Vector3 newPosition, Quaternion newRotation)
     {
         transform.position = newPosition;
         
         transform.rotation = newRotation;
     }
 }

Basicly, it should send the RPC called Sync everytime the player moves more than 0.1 units or rotates 1 degree. It does it, but twice per second.

Heres a video : LINK - in the video you can see what i mean, and when the red player health reaches 0, there was a delay.

Comment
Add comment · Show 4
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 Benproductions1 · Dec 26, 2013 at 06:24 AM 1
Share

Why would you want to set the send rate ever 2.5 seconds?

Firstly variables don't change unless you change them, so why set it more than once?

Secondly if you want it to stay the same just change it in the network settings of your project and be done with it

avatar image DryTear · Dec 26, 2013 at 05:11 PM 0
Share

because even if i do change it every 2.5 seconds, it doesnt change the send rate, ive checked it in the Edit>Networking and the Sendrate is set to 15, still no luck. Is it because im using U3D 4.3.2?

avatar image Benproductions1 · Dec 27, 2013 at 12:51 AM 0
Share

If it's set to 15 in the project settings why are you setting it again in the scripts? Why post that script if you're not having a problem changing the send-rate, but rather a problem with sending the data. It would be infinitely more useful if you posted how you're sending the data, rather than how you're (not) changing the send-rate.

avatar image DryTear · Dec 27, 2013 at 07:19 PM 0
Share

i dont know why the send rate is so slow, that it sends only 2 times per second ( the rpcs ). When the player i control moves, it moves fine with 60FPS, on the other screens, the position updates only twice per sec, and same goes to shooting, sending messages and updating a text over RPC. And i posted that script to show that ive tried forcefuly change the sendRate

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiloblargh · Dec 27, 2013 at 07:55 PM

If you are using RPCs to update the position, sendRate should not affect that. Network.sendRate controls how often it updates if you are using automatic position synch from the NetworkView's observed property. There is probably something wrong with how you are sending the RPC or checking when to send it, in the relevant part of the script that you didn't post.

Comment
Add comment · Show 6 · 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 Benproductions1 · Dec 27, 2013 at 11:23 PM 0
Share

I'm not too sure that sendrate doesn't affect RPC's. By all means, Unity could put all your RPC calls into the same packet every 15th of a second. With the amount of RPC gettings sent in my project that is most likely what is actually happening?

avatar image DryTear · Dec 29, 2013 at 07:04 PM 0
Share

so .sendRate has nothing to do with RPCs?

avatar image Kiloblargh · Dec 29, 2013 at 09:51 PM 0
Share

RPCs are sent when you send them. Post the part of your script that sends the RPCs. But I watched the video and even if you fix your RPC code to send more often, it will still look awfully jerky for the client if you are moving the player from one discreet position to another every time an RPC arrives. Ins$$anonymous$$d you should be moving it every frame on the client side and using the received position to smoothly correct from the predicted position toward the actual position.

avatar image Kiloblargh · Dec 30, 2013 at 01:29 AM 0
Share

Ok, your script looks like it should work, I don't know what the problem is. Put a` Debug.Log` message in the if() after networkView.RPC and another one in the RPC function and see how often it is getting called on the server side.

avatar image DryTear · Dec 30, 2013 at 07:48 PM 0
Share

https://www.dropbox.com/s/fsgk5kiprhzshzs/Screen%20Shot%202013-12-30%20at%202.46.35%20P$$anonymous$$.png

it does it fine, every time i move 0.1 units or rotate a degree, it does everything fine.

Show more comments

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

19 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 avatar image avatar image

Related Questions

Send RPC in 2 scene 0 Answers

RPC calls client to server Errors 1 Answer

Getting rotation to work on client 1 Answer

Network RPC 1 Answer

Does Unity merge RPC calls into one packet per tick? 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