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.

Understanding Set Custom Properites and CAS

2021-10-16 09:03:15

Hi there

I am just looking over the Photon documenation and want to verify if what I am doing is correct.

When I join a new room, I am creating a new Hashtable for the room and using SetCustomProperties so it is accesable between all players:

Now if a player collects wood, I am calling this method:

I am then using the OnRoomPropertiesUpdate to update the UI text for all players.

This works across 2 differnt builds. Is this above implementation correct?

CAS: Now if I wanted the piece of wood to be a unique item, so only one in the scene and it belongs to one player how would I do this? I have seen that you add a expectedProperties hashtable to the SetCustomProperties but how would I go around doing this?


[Deleted User]
2021-10-17 20:21:03

Hi, players also have custom properties just like the room does, you could store the unique wood in their player custom properties for the sake of continuity. Your implementation is fine, but please be aware that type casting can potentially be dangerous in a production environment where bad actors might have influence over your game code. If your game is competitive, make sure you error handle these types of cast operations thoroughly.

Please see the documentation for player properties:

Photon Unity Networking 2: Player Class Reference
Custom Properties are a set of string keys and arbitrary values which is synchronized for the players in a Room. They are available when the client enters the room, as they are in the response of OpJoin and OpCreate.

Back to top