Setting and serializing an object state visible/invisible through a random variable?

Options
ruse
ruse
Im using PhotonEngine. There are two characters(Object) and a random variable(Int). In the beginning of the game, if the variable is equal to 1, the first character should be visible and the other one should be invisible. Avatars are for equalizing the animator avatar and character avatar. Code is below;
.
.
.
 Animator anim;
 public Avatar char1;
 public Avatar char2;
 public GameObject char1Obj;
 public GameObject char2Obj;
 private PhotonView PhotonView;
 private void Start()
 {
     PhotonView = GetComponent<PhotonView>();
     anim = GetComponent<Animator>();
     randomChar = Random.Range(1, 3);
     if (randomChar == 1)
     {
         char1Obj.SetActive(true);
         char2Obj.SetActive(false);
         anim.avatar = char1;
         playerRole.mannequin = char1Obj;
     }
     else
     {
         char2Obj.SetActive(true);
         char1Obj.SetActive(false);
         anim.avatar = char2;
         playerRole.mannequin = char2Obj;
     }
 }
 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
        if (stream.isWriting)
        {
            stream.SendNext(char1Obj.activeSelf);
            stream.SendNext(char2Obj.activeSelf);
        }
        else
        {
            char1Obj.SetActive((bool) stream.ReceiveNext());
            char2Obj.SetActive((bool) stream.ReceiveNext());
        }
 }

.
.
.
This should work but it doesn't serialize the character object states. Any idea to fix this issue?

Comments

This discussion has been closed.