posted an update

Completed my network connection test. Now I have a peer-to-peer connection established.

Next up is to start sending data packets, which is a whole mess itself. I have to architect how and when to packet data, unpacket it, I need to work out how to route it to the correct entity, I need to add in compression and all that jazz.

To send hand tracking data is a lot of data to send. Finger positions and rotations, 3 floats for position, 4 for rotation, for every tracked joint is a hell of a lot. Fortunately I've done this before and have a good plan in my head for dramatically shrinking the size of data I need to send.

One thing I do is make all finger joint positions relative to their parent. Unless you have freakish hands the distance from their parents can't be more than say 15cm, so the floats I pack don't need to have a full floats worth of precision. I also do the same for hands relative to the head. And for angles I clamp them within a range so I don't need to cover the whole range.

Once I get a min and max range for a float, I determine the precision I need. I divide the difference between min and max by the precision, to get the number of steps I need to support. Then I round to the the closest step and convert to an int, and send that in my data packet.

For example, if my range is 2.0 to 8.0 and I need to support precision of .25: (8.0 - 2.0) = 6 6 / .25 = 24 steps. Int range: 0 to 24 which I can then compress into 5 bits instead of sending a 32 bit float

So, if my value was 3.78 3.78 - Min(2.0) = 1.78 1.78 / .25 = 7.12 Round to int: 7

Then on the receiving end I do 7 * .25 = 1.75 1.75 + Min(2.0) = 3.75

So I lose precision from 3.78 to 3.75, but the precision loss is tunable.

On another note, on the client sending the data, to make things deterministic, I also round their own copies of the variables this way before using them in other calculations. This way I know that both clients are making the same calculations from the same starting points, without the fuzziness you normally get from floats.

This is also useful when checking client side prediction, you can check the bits are the same. I have done this in previous unity projects, but for the scope of this jam and my custom engine I won't have client side prediction/rollback and server authority. But thats the plan for the engine later on.

Not sure if this is the typical network approach, but I just kinda came up with this myself years ago.

Log in or sign up for Devpost to join the conversation.