Ordering reliable and unreliable messages in UNET
Hi! I wonder if anyone can help me here
Is my understanding correct that different channels in the Unity networking work independently from each other? As in a message sent through QosType.ReliableSequenced and a message sent through QosType.UnreliableSequenced aren't sequenced after each other.
What if I wanted a transport that could transmit both reliable and unreliable messages in a determined sequence? Is there a way to achieve that in Unet?
Answer by Absent_TK421 · Feb 14, 2019 at 02:28 AM
Hi @lukanin , Yes it is correct that they are separate channels of information. Since each message type operates on a different quality level, it would be impossible to naturally order them in one channel (imagine a "reliable" message waiting on an "unreliable" message. That would not be reasonable.) I can offer two answers to your question, one is more of a methodology fix and the other is a code fix. Without knowing the specifics of your game, I'd say consider each and know that it may be helpful to try to do both.
Methodology Generally from a professional design perspective, if we have something which MUST arrive in a certain order then we prefer to send that information in a single channel which fits that requirement. For example, if I need to send info about player's turns in a board game, then I'd try to send all of that info ReliableSequenced because the most important aspect of it is that I always get it, and in a certain order. In such a situation I would never want to skip a player turn, so this makes sense. On the other hand if I were sending player position updates in an FPS, I might consider sending that in an unreliable way because I would want it to get there as fast as possible, and then let the client interpolate when i miss a packet. Both of these options can be helped by the code fix below.
Code In regard to ordering messages, typically multiplayer games will implement either a "Tick" system or a timestamp system. In this case, I send along a tick number or a timestamp with my messages. The game systems then use this time info to decide how to order network messages. With a raw timestamp you can order messages precisely, or with a tick number you can group commands which all happen on the same "tick" of your game logic. If you're creating a turn-based game, you could instead include a turn number or something similar, again just a way of ordering your messages regardless of which channel you get them on. Of course, the goal is to get the order info you need without sending any more data than you have to. so if an int would do, try to send that instead of a full timestamp.
Your answer
Follow this Question
Related Questions
Send Message inside ClientScene.AddPlayer 0 Answers
Rotation sync over network best practices (especially; direction) 0 Answers
[Unet] How to Use SendBytesToPlayer? 1 Answer
What's wrong with my script ? 0 Answers
UNET Online Match Making? 1 Answer