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
Documentation

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.

Read More on
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.

Setting custom player properties?

LeytonMate
2020-04-28 16:46:46

I'm trying to load in player weapons from a static scriptable object, and I'm doing this by first:
Adding a custom player property per weapon part
Then, getting the player's custom properties and loading that in

for some reason this doesn't work. The script that does this isn't disabled for other players, should I make it run only if isMine is true?

Here's what I've got so far:

For some reason this doesn't work consistently every time, and sometimes only works for the person who joined first. Anyone know what's wrong?

Comments

LeytonMate
2020-04-29 15:43:49

Updated my code a bit, works more consistently but still doesn't synchronise a lot of the time.

This method is ran on Start() for every person in the room. I've crammed it into one splittable string now which works a lot more

LeytonMate
2020-04-29 16:07:50

bump

LeytonMate
2020-04-29 18:56:32

bump

JohnTube
2020-05-01 10:22:13

Hi @LeytonMate,

Did you implement OnPhotonPlayerPropertiesChanged callback?
It will tell you that properties have been updated.

Make sure clients are joined to the same room.
Check error logs.

Side notes (optimization):
Also, can you split this into multiple properties instead of a one with a single long string value?
It's better especially if each part of that string is updated separately individually with different frequencies.
Also you could maybe replace the string value with int/byte/short as index or pointer for enum or actual value on client for efficiency.

LeytonMate
2020-05-01 13:34:47

How will I be able to tell that the property that changed was the weapons?

LeytonMate
2020-05-04 15:19:47

Also, how can i tell whos properties changed?
@JohnTube

JohnTube
2020-05-04 16:54:27

Hi @LeytonMate,

as you can read in the documentation of the callback:

and the hashtable has the key/value pairs that have been changed.
e.g.

Note: it would help to make some efforts and do some research instead of bump spam.

LeytonMate
2020-05-04 17:22:49

I did that, but when comparing it against the PhotonNetwork.player it says it's null?

Back to top