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
1
Question by applejuices · Nov 15, 2014 at 03:52 PM · networkbytes

What is the size of a float vs the size of a Vector3 over a network(in Bytes)?

Im making a (Most unique) shooter in unity, but when i fire it does an update setting a vector three, and it bumps up my 600 bytes a second to nearly 1200 byes a sec. I know this is low but how would I fix that? I would like to know if sending floats in more efficient. Or what about a 20 long string? which of the three is most efficient? I know I could test this but its on a small scale and I dont have a big scale yet.

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
1

Answer by Bunny83 · Nov 15, 2014 at 04:12 PM

A single float value has 4 bytes. Since a vector3 contains 3 floats it's of course 3*4 == 12 bytes. A string would probably way worse as one character is usually encoded as 16 bit unicode character. So each character will have 2 bytes and an additional length of usually 4 bytes (1 integer) for the string itself.

Since that's all you have provided that's all i can answer.

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 applejuices · Nov 15, 2014 at 04:28 PM 0
Share

I dont nderstand why my code generates 600+ more bytes rather than 12(I fire ten tiems a sec) lemme post code

avatar image applejuices · Nov 15, 2014 at 04:31 PM 0
Share
 using UnityEngine;
 using System.Collections;
 
 public class GunScript : $$anonymous$$onoBehaviour {
     public int $$anonymous$$odeFire = 0;
     public float Firespeed;
     public RaycastHit Hit;
     public LineRenderer Rendy;
     public Camera Cam;
     public int Damage = 20;
     public float $$anonymous$$odifier;
     public AudioSource PlaySound;
 
     // Use this for initialization
     void TurnBulletOff(){
         networkView.RPC("RPCFire",RPC$$anonymous$$ode.AllBuffered,transform.position);
         }
     void Increment(){
         Fire();
 
         }
     [RPC]
     void RPCFire(Vector3 Pos ){
         Rendy.SetPosition(0,transform.position);
         Rendy.SetPosition (1, Pos);
         }
     void Fire(){
 
         if (Physics.Raycast (Cam.camera.ScreenPointToRay(Input.mousePosition), out Hit, 3000)) {
             PlaySound.Play();
             CancelInvoke("TurnBulletOff");
             Invoke("TurnBulletOff",.5f);
             networkView.RPC("RPCFire",RPC$$anonymous$$ode.AllBuffered,Hit.point);
             print(Hit.point);
             if(Hit.transform.tag == "Player"){
                 int HealthLower = Hit.transform.parent.transform.GetComponent<HealthScript>().Health;
                 int SetDam = Random.Range(Damage - 5, Damage + 5);
             
                 int LowHealth = HealthLower - SetDam;
 
                 //
             Hit.transform.parent.transform.networkView.RPC("SetHealth",RPC$$anonymous$$ode.AllBuffered, LowHealth);
             }
                 }
     }
     // Update is called once per frame
     void Update () {
     if (networkView.is$$anonymous$$ine) {
             if($$anonymous$$odeFire == 0){
             if(Input.Get$$anonymous$$ouseButtonDown(0)){
             
                 Fire();
                 }
 
             }
             if($$anonymous$$odeFire == 1){
                 if(Input.Get$$anonymous$$ouseButtonDown(0)){
                     InvokeRepeating("Increment",0.05f, Firespeed);
                 }
                 if(Input.Get$$anonymous$$ouseButtonUp(0)){
                     CancelInvoke("Increment");
                 }
             }
             
             }
     }
 }
 

avatar image applejuices · Nov 15, 2014 at 04:57 PM 0
Share

uhh yea htere is the code

avatar image Bunny83 · Nov 15, 2014 at 05:23 PM 1
Share

@applejuices: Well, you send a RPC. This call has of course additional information to transmit, like what method it should call on the other side, the mode / receiver, count and type of parameters and the parameters itself.

avatar image applejuices · Nov 15, 2014 at 05:58 PM 0
Share

Oh riiiight. okay I got it !

avatar image
0

Answer by Owen-Reynolds · Nov 15, 2014 at 05:26 PM

That 600 to 1200 bytes is the network traffic? Isn't that "raw" bytes, including all the headers? For example, each RPC also includes the name of the sending function, and probably a timeStamp. What sort of RPC was giving you the 600 bytes figure?

If your same RPC sent one extra Vector3, I imagine you'd see just a small increase. How much traffic does an RPC with no parms generate?

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

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

Related Questions

How to send bytes data between two different build 1 Answer

Unity Web Request 2 Answers

Upgrading from Legacy Networking to new networking 2019.1 0 Answers

Unity knowing if connected to cellular not WiFi 0 Answers

How do I fix the problem with animator.Play() using Mirror Network in Unity. 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