C++ pack translation ,rotation ,animation like PUN

How did you achieve in Photon PUN to make the translation, rotation and animation values to be packed and send in so little number of messages per frame? I 'm trying to do the same with C++ SDK and UE4

Comments

  • @Tobias, could you explain, please, what exactly we are doing in PUN in this regards?
  • How is it going @Tobias ? :)
  • Hi,

    - You need to first analyze what you really need, if you have a 2d gameplay, rotation could only be necessary as a float for one axis because your character would never rotate around the other two. It goes for position as well.

    - Then for animation, you need to take out all possible values that can be deduced from the position and rotation, for example, don't send the speed parameter, instead have the logic deduced the speed from the last few positions, this will save bandwidth at the possible cost of inaccuracy, you'll have to balance that of course.

    - alter the send rate, it's critical too, send the least amount of times per second, again it's a balance and depends on your game play, below 10 is preferable.

    - use RPC/player custom properties for granular change of data. Although with delta reliable compression, you can get pretty close to the same optimization as sending RPC/ setting player custom props only when needed.

    - Make sure you don't try to bundle everything in a bytearray and send it all in one go, instead rely on "Reliable delta compressed" observe option, and send granular data to the stream ( .SendNext()), pun will send null when it finds that the data hasn't change, and that's a big deal for optimization.

    I would go as far as separating vector 3 into individual floats, so that if your character is moving along one axis, the other two will be null, it's better then sending a vector3 with 3 floats always no matter what.

    - then comes the magic of compressing floats, I am not going to go into details, but instead of sending a full float, you could sending ints, or bytes representing a portion/range of a float./ For example, expressing the rotation using a float might be too much accuracy, and if 1 or 2 degree is not a big deal, then you only need a range of 0-360, bytes can help you do that and will reduce the bandwith.

    For this, the best asset I know of is this:

    https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256

    It features a full blown choice of compression and setup for all your usual data.

    Bye,

    Jean
  • Hi,

    I misunderstood your question :) but the answer is in there still I think.

    if you use Delta reliable compression for your observed component and you use SendNext() for each distinct value, then pun will send null when it detects that the value is the same, that is likely playing a role in the difference you see if you compare.

    then, there is a difference between the send rate and the info you send. you can send the position once per frame or 20 times per frame, the two are not linked but combined, make up for the bandwidth.

    What tool and setup to you use to compare your solution with PUN?

    Bye,

    Jean
  • Thank you so much for this information, I'm going to study it to replicate the same behavior with unreal but in another way,not component tied but functions and delegates, and lambdas ,so, I'm getting ready a plugin for marketplace, I've named it PhotonCloudAPI for UE4, I'm linking you in the docs.

    http://photonue4.xixgames.com/