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.

Change value of custom property

2015-02-02 09:45:12

I made some custom properties for my players (one of them is its health) how do you change the value of a custom property? :oops:


2015-02-02 15:45:50

I typically use a static extensions class. If you put this in a file you will then have extensions on the PhotonPlayer class.

2015-02-04 09:08:21

Thank you, that worked. :D

EDIT: I got a problem though, I used this to add the Health property to the photonplayer but when I run my "hit" function the player only loses health on the player who is attacking and not in the player who is getting hit, also after like a second the player gets its health back, which I think it means its synchronizing with the player who is getting hit who is at full health

2015-02-05 08:24:57

_PhotonPlayer is attacker? Then update health of hit player, not attacker.

2015-02-05 12:38:30

@vadim wrote:

_PhotonPlayer is attacker? Then update health of hit player, not attacker.

err no _photonPlayer is the player who got hit. You may be confused because of the variable "int AttackerID" but that is the ID of the person who attacked this player so when the player dies the last person who attacked this player gets the score. The attacker has nothing on this actually, the ID of the attacker and the damage are carried by the projectile, the projectiles also are the ones who trigger this function.

2015-02-09 14:51:03

Make sure that you update health only once and always on same client for particular player (usually owner of this player) If hit detected on client other than owner, sen RPC to owner and update health there.

Back to top