Photon SendNext doesn't work

The code I have:

using UnityEngine;
using System.Collections;

public class Doors : Photon.MonoBehaviour {
	public bool openDoors = false;
	Animator anim;

	void Start() {
		anim = GetComponent<Animator>();
	}

	void Update() {
		if (photonView.isMine) {
			if (openDoors) {
				anim.SetBool ("Open", true);
			} else {	
				anim.SetBool ("Open", false);
			}
		} else {
			if(openDoors) {
				anim.SetBool ("Open", true);
			} else {	
				anim.SetBool ("Open", false);
			}
		}
		Debug.LogError (openDoors);
	}

	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
		if (stream.isWriting) {
			// This is OUR player
			
			stream.SendNext(anim.GetBool("Open"));

		} else {
			// And this is someone else's player
			
			openDoors = (bool)stream.ReceiveNext();
		}
	}

	void OnGUI() {
		GUI.Label (new Rect(10,50,100,20), openDoors + " - " + anim);
	}
	
}

It’s working for local, the second receiver isn’t getting the update. That means when I want to open the door, it willn’t change bool to true.

What do I want? Change the boolean.

I’ve tried several things, debug if is that updating - nothing.
So atleast I know it doesn’t send the Bool.

  • Changing in stream.SendNext(openDoors);

  • Changing in anim.SetBool("Open", (bool)stream.ReceiveNext());

It doesn’t even sending error, warning or anything.

Unity3D:

Unity3D

Make sure you “observe” this script in the GameObject’s PhotonView. Else, OnPhotonSerializeView doesn’t get called.

With the default “Observe Option” (set in the PhotonView component), the value is only sent when it changes (and when someone joins). To test, you could use “Unreliable”, which will send it 10x per second. You should not do this in a release though. “Delta compressed” or “Unreliable On Change” are better options, you just have to buffer the latest value.

In worst case, explicitly cast the sent value to bool: (bool)anim.GetBool(“Open”)

I tried sending bool in PUN 1.26 just now and it works.