The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

OnPlayerPropertiesUpdate not called?

2018-11-09 18:09:22

I am just beginning with PUN (porting a project using UNET). Everything has worked great so far (well not far yet).
But for the life of me I can't figure out when I set Player custom property the OnPlayerPropertiesUpdate is not called.

I am setting the properties as follows:

Hashtable hash = new Hashtable();  
hash["driver"] = driver; //driver is int value  

But on my other class (which inherits MonoBehaviourPunCallbacks) the method is not getting called:

    public override void OnPlayerPropertiesUpdate(Player target, Hashtable changedProps)  
		Debug.Log("MPLobbyPlayer: OnPlayerPropertiesUpdate() " + changedProps.ToString());  
		if (target == photonView.Owner && changedProps.ContainsKey("driver")) {  

Am I missing extra steps here? I can verify on the masterclient (where I set the custom properties) that the properties are actually getting set. Just the callback is not called. I've understood the OnPlayerPropertiesUpdate() should be automatically called even on the client that is calling SetCustomProperties(), right?


2018-11-10 09:16:53

Hi @zilp,

Thank you for choosing Photon!

Yes, what you have reported (OnPlayerPropertiesUpdate "not automatically called on the client that is calling SetCustomProperties()" but should be triggered for the others) is the actual behaviour. We will discuss internally if it should be the correct or intended behaviour or not.

Here are few things to try however:

  1. Verify RoomOptions.BroadcastPropsChangeToAll is set to true when you create rooms. This will enable sending the PropertiesChanged event to everyone inside the room including the player whose properties have changed or the one who made the change. This is supported on the Photon Cloud only for now and not on the self-hosted Photon Server.
  2. Use CAS ("Check-And-Swap" or "Compare-And-Set") feature using Expected Properties if possible. This will also trigger a PropertiesChanged event broadcast to everyone inside the room in case of success.

The difference between 1 and 2, in the current code base:

  1. will set the custom properties locally before making the call to the server.
  2. will not set any properties locally until getting ack/confirmation/order/event from the server.

2018-11-10 09:29:00

Upon further inspection, the OnPlayerPropertiesUpdate is indeed called on other MonoBehaviourPunCallbacks objects.
The one where it is not called is the one I have attached to a prefab and which instantiate when OnJoinedRoom() gets called:
PhotonNetwork.Instantiate(, new Vector3(0f,5f,0f), Quaternion.identity, 0);

This prefab has the PhotonView component and a custom component which inherits the MonoBehaviourPunCallbacks. For some reason for this custom component the OnPlayerPropertiesUpdate does not get called.

2018-11-10 09:51:27

@JohnTube do you have insight on if I am supposed to something else for when instancing prefabs with MonoBehaviourPunCallbacks - for them to actually get the callbacks? Or is this something I should not be doing? I can of course work around this issue by refreshing these components my self from the manager class (which has the OnPlayerPropertiesUpdate() call working properly). But I'd like to verify this is expected behaviour?

Also, in the PUN2 documentation for OnPlayerPropertiesUpdate
"Changing properties must be done by Player.SetCustomProperties, which causes this callback locally, too."

2018-11-10 10:36:43

@JohnTube ok - this was super stupid of me :dizzy:

I had infact overwritten the OnEnable() method on my subclass, without calling base.OnEnable(); - Not realising that there was actually implementation in MonoBehaviourPunCallbacks that was setting the PhotonNetwork.AddCallbackTarget(this);

So problem solved :)

2018-11-26 23:39:03

@zilp I'm a bit confused - did you find that the callback was in fact being called locally as is documented? I'm migrating from pun 1 to 2, and I haven't been able to get this callback to fire yet in 2. It originally worked this way in 1.

2018-11-27 10:17:41

Hi @wadams201,

Thank you for choosing Photon!

Are you using Photon Cloud or self-hosted Photon Server?
Did you try my suggestions from here.

Back to top