Receive incoming position & rotation data as if it were parented differently on different clients?

Options
Hi! I have a drawing app where everyone in the area is looking at their virtual tablet screen. I already synchronize everyone's PhotonView pen which successfully leaves a trail, but it is it somehow possible to convert the incoming data so that it's always shown relative to the watching client's virtual tablet transform -- so that the relevant client will see all trails on one screen as if merged? (As if the object had a different parent on each client.)



(I tried IPunObservable + OnPhotonSerializeView, while ensuring the Pen is an observed PhotonView component, but it doesn't fire. I figured it would allow me to re-write the position & rotation values before they are applied, by converting them relative to each virtual tablet. But maybe this isn't even the right approach.) Thanks!

Comments

  • Philipp
    Options
    I have it working now, commenting here for a future searcher's reference.

    First of all, after adding IPunObservable to the MonoBehaviour, in this case my Pen, I still had to ensure I replaced in that Pen's PhotonView observed components list the existing PhotonTransformView with the Pen (to then delete the PhotonTransformView component).

    Now in the pen, I can add something along these lines (not using lerp smoothing towards targets yet):
        public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
        {
            if (stream.IsWriting)
            {
                stream.SendNext(transform.position);
                stream.SendNext(transform.eulerAngles);
            }
            else
            {
                transform.position    = (Vector3) stream.ReceiveNext();
                transform.eulerAngles = (Vector3) stream.ReceiveNext();
    
                if (repositionSource != null && repositionTarget != null)
                {
                    Transform oldParent = transform.parent;
    
                    transform.parent = repositionSource;
                    Vector3 localPosition = transform.localPosition;
                    Vector3 localRotation = transform.localEulerAngles;
                    
                    transform.parent = repositionTarget;
                    transform.localPosition    = localPosition;
                    transform.localEulerAngles = localRotation;
                    
                    transform.parent = oldParent;
                }
            }
        }