New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

Need help with smoothing poses for the RemoteAvatar

MTGTech3MTGTech3 Posts: 1
I have set up a multiplayer scene in unity using Photon. I have the LocalAvatar (imported directly from OvrAvatar > Content > Prefabs)set to record packets which then sends packet poses over the photon network by using oculus RemoteLoobackManager (modified to work with Photon). The poses are sent to the other players RemoteAvatar (also imported from OvrAvatar > Content > Prefabs). Everything works fine except that the RemoteAvatar does not do any Interpolation between pose frames. The fingers does however work smoothly but the rest of the avatar jitters and lags. Is there anyone who have a solution to this issue?. 

the issue is demonstrated in this youtube clip:

it is hard to see that the fingers are smooth but if you look at the video frame by frame you can see this.

Here is the code for the modified RemoteLoopbackManager:

    public OvrAvatar LocalAvatar;
    public OvrAvatar LoopbackAvatar;
    byte[] data;

    int packetSequence = 0;

     void Start () {
        LocalAvatar.RecordPackets = true;
        LocalAvatar.PacketRecorded += OnLocalAvatarPacketRecorded;

    void OnLocalAvatarPacketRecorded(object sender, OvrAvatar.PacketEventArgs args)
        using (MemoryStream outputStream = new MemoryStream())
            BinaryWriter writer = new BinaryWriter(outputStream);
//          SendPacketData(outputStream.ToArray());
	    data = outputStream.ToArray();


//    void SendPacketData(byte[] data)
//    {
//        // Loopback by just "receiving" the data
//        ReceivePacketData(data);
//    }
    void ReceivePacketData(byte[] data)
        using (MemoryStream inputStream = new MemoryStream(data))
            BinaryReader reader = new BinaryReader(inputStream);
            int sequence = reader.ReadInt32();
            OvrAvatarPacket packet = OvrAvatarPacket.Read(inputStream);
            LoopbackAvatar.GetComponent<OvrAvatarRemoteDriver>().QueuePacket(sequence, packet);
	void Update(){

	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		if (stream.isWriting)
			stream.SendNext (data);
			data = (byte[])stream.ReceiveNext ();
			ReceivePacketData (data);


  • chrisnoletchrisnolet Posts: 15
    I looks like your `data` global is being continually overwritten with every call to `OnLocalAvatarPacketRecorded`. If `OnPhotonSerializeView` isn't being called as often as `OnLocalAvatarPacketRecorded`, then you will be dropping packets. I suspect this is what's happening.

    You may like to keep a list of byte arrays and send them all on `OnPhotonSerializeView`.
Sign In or Register to comment.