Controlling many separate objects on field with takeover

I want to make a scene with many objects that will be moving and each player will be able to take it, drop it and to some stuff with it. Still I did encounter some difficulties.
For now i'm creating new objects and attach scripts with photonTransformViewClassic. It works fine while I move items carefully wihout interruptions from other players.
This items have ability to group relatively to each other. And I encounter problem with syncing their positions when they are grouping to one parent.
Idea is that unreliable on change update will prevent many info updates if there will be more than 500 objects on scene. And also grouped objects stop syncing separately and new PhotonTransform will be handling group. But when I turning off sync of an object it teleports to not expected locations to one of the player.
May be I miss something. May be I should use better way.
Players transfer ownership by requesting each other to get controll over each object too btw. I also wanted to make something like neutral owner, but it seems like it's not a thing cause one player have to be an owner for info syncing. Any help will be appreciated :#


  • Jasper_wJasper_w
    edited July 1
    I advise you to use a custom IPunObservable.OnPhotonSerializeView method to synchronize the position, I will share my code for a pickupable weapon with you (scene is the owner):

        void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
            if (stream.IsWriting)
             stream.SendNext(WeaponHolder ? WeaponHolder.ViewID);
             if (!WeaponHolder)
             int ViewID = (int)stream.ReceiveNext();
             WeaponHolder = Find(ViewID);
             magazineRounds = (int)stream.ReceiveNext();
             spareRounds = (int)stream.ReceiveNext();
             correctPosition = (Vector3)stream.ReceiveNext();
             correctRotation = Quaternion.Euler((Vector3)stream.ReceiveNext());
    In the Update method:
    if (!WeaponHolder && !photonView.IsMine)
                    transform.position = Vector3.Lerp(transform.position, correctPosition, Time.deltaTime * 5);
                    transform.rotation = Quaternion.Lerp(transform.rotation, correctRotation, Time.deltaTime * lerpExponent);
Sign In or Register to comment.