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 Fusion.

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.

How to set Player Custom Properties in Photon fusion?

2022-09-01 10:52:30

I have used PUN2 previously for making multiplayer turn based games . It has a method for storing local player's custom data which can be read by other players in the room.

Now I am trying to do same using Photon fusion but can't find a way to get around it?

Does anyone have any Ideas or alternate solution around it?


2022-09-01 11:57:27

While Custom Properties in PUN were Hashtables with setter methods, Fusion synchronizes plain C# properties instead: As part of a NetworkBehaviour, auto-implemented properties just need a [Networked] attribute to become part of the game state.

So you write a NetworkBehaviour and use it per player. The players can send an RPC to set the values, which need to be set by the host/server.

2022-09-01 12:34:34

So , What I get from this is that whenever any player joins a session, it calls an RPC to every other client with its properties set as a parameter to that RPC method and everyone gets the user data of that connected client ?

Am I getting it right?

2022-09-02 10:19:37

Almost right.

The client send the RPC to the host/server and this sets networked properties on a NetworkBehaviour-instance, which is for this player.

Then those values become available to the other players.

2022-10-03 16:56:08

How would you recommend going about setting player properties that can be used for matchmaking?

We are using Shared mode. Players Join the lobby and then search through the session list in the OnSessionListUpdated callback. So we need to know some data about the player before their Player instance (which inherits from NetworkBehaviour) is instantiated after joining a session.

Our use case is we have a game that has two character types on different teams. The player chooses which character type in the front end, and there can be up to three players on each team.

Ideally we would have a way to find player custom data in the OnPlayerJoined callback so that the session properties for how many members are on each team can be updated immediately. Currently the delay between a player joining, them instantiating their own Player instance and syncing the team id using the [Networked] attribute is enough for other players to join the session for the same team, even though that team is already full and we have to kick them.

In short we are looking to implement some form of Team Matchmaking. Thank you.

2022-12-07 16:15:12

Just a bump of my last question a couple months ago above?

2023-02-06 23:32:15

Hi @Amuzo maybe the answer is here:

2023-02-16 17:48:17

Thanks @Pesseba,

Unfortunately the issue is more the delay after a runner joining the session with a PlayerRef and instantiating the game object that can hold the NetworkBehaviour that @Tobias mentions with [Networked] attributes that are synced over network and so able to update session properties about how many players on on each team.

It can be enough time for another player to join for the same team.

So if there was a way to get information about the team the player has chosen at the point of joining the session, say in the PlayerRef for instance it would prevent this, or at least reduce it.

Back to top