- Home /
network bandwith reliable/unreliable int/float
Hi,
i want to do a 2D game with 16 players and more. i prefer to think now about network bandwith.
i have a script attached and observed by a networkview in a object "networkplayer". it is in unreliable mode for: x, y, angle, state (jumping, have flag, ..), life
1) x, y, angle are float: i don't know how much ko/s it is. maybe if i convert it in a int before sending, it will consume less? like: sender: Xisend= (int)myX*1000 reciever : myX = (float)Xirecieve/1000
thereby the comma is less precise but cost less bandwith because it is int?
2) life, state : don't change every frame but 10/20 frames. is it a good idea to set them in a different networkview on Reliable, will it bring really something?
3) for damage, i use RPC. but i am afraid that it could freeze game when lags. is it a good idea to set a reliable value, always at 0. and when there is damage, set to the amount of damage? then put it again a 0.
sry for my poor english. thx
Answer by Benproductions1 · May 27, 2013 at 04:09 AM
Hello,
Since Unity uses UDP, and the UDP header is quite large in data, most of your data you'll be sending will be in the header of the packets, not the content. Therefore the difference between an int and a float will make WAY less difference than reducing the number of packets in general.
But seriously...
The amount of data you are going to send is not even going to be close to that of (for instance) a youtube video. There is such a thing as over optimizing :)
As for reliable vs unreliable: Unreliable just means there will be no confirmation package, but it also means your packets might not arrive... I preffer losless over lossy, in both general and specific cases :)
For damage... why would it cause a freeze??? wtf are you smoking :P For any event, RPC's are better than networkView automatic syncing. Prefferably convert everything to RPC's so that even your movement and such is event driven :)
Hope this helps,
Benproductions1
Thank you for your answer. i don't smoke ;)
in the unity documentation, it is written :
For example, synchronizing a Transform involves transmitting nine float values (three Vector3s with three floats each), which equates to 36 Bytes per update. If the server is running with eight clients and using the default update frequency then it will receive 4,320 $$anonymous$$Bytes/s (8*36*15) or 34.6$$anonymous$$bits/s and transmit 30.2 $$anonymous$$Bytes/s (8*7*36*15) or 242$$anonymous$$bits/s
so i was afraid but i didn't read the right thing : $$anonymous$$o/s but it is $$anonymous$$Bits, it's not the same ^^ that's ~30 ko/s. 16 players : 60ko/s . that's good !
i started the game using just RPC but it seemed heavy. but i was because i used them every frame :p
but at a send rate of 20, its maybe a good thing because it is possible to choose who recieve the RPC. in my case, only close players to avoid unnecessary bandwidth (for players, not for server but i will be dedicated)
1) are you sure reliable send at the 15-20 send rate like unreliable(but with check) or it is send only when it change?(that mean less packets sended)
2) you mean the important is less packets. do you think one packet for a player is important (so 16 packets with 16 players)? i mean my "state" value that go from 1 to 9 can be multiply with life and sended together? maybe i search the little freak as we say in french :p
This should be a comment, not an answer. It does not answer the question!!!!
That said:
1) I believe it's the same as unreliable. Just a constant flow :)
2) Think of it this way: Your not going to send packets that are large enough to make a difference, so unless your strea$$anonymous$$g a ton of data (similar to games like $$anonymous$$ecraft) Nothing you do will make a difference :)
If you really want to reduce the amount of data, reduce the amount of RPC's called or decrease the sendrate, but really... it's not worth it :)
If you really want to reduce everything, use your own TCP system, ins$$anonymous$$d of Unity's UDP :)
i prefer see my post written in big font :p
thank you for your answer! network side is good now, there is just only the others 98% to finish now ;)
@wozhdal2 Sorry, but I can't take that as a joke. Convert it to a comment :)
If it's fixed now, please accept my answer so this question gets finished :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613102922im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
measure bandwidth/internet speed??? 0 Answers
Networking Help Needed 0 Answers
Networkview on prefab consumes bandwidth or safe to use? 0 Answers
Custom network ID values 0 Answers