- Home /
Question by
MrMelonBoi · Oct 24, 2021 at 03:55 PM ·
photonrpcpun
Photon PUN rpc function doesnt update the variable to a new joined player
So im making a simple 2d shooter and i have a rpc function for taking damage that basicly decreases health variable by damage income. Two players join, one decreases others life to 7 and leaves but when it reconnects, other players health is back to 15 (default) on its screen. Any idea why?
public void takeDamage(float damage)
{
view.RPC("takeDamageRPC", RpcTarget.AllBuffered, damage);
}
[PunRPC]
void takeDamageRPC(float damageIncome)
{
health = health - damageIncome;
lifeCount.text = health.ToString();
}
Also at the start I set players own health to 15 at spawn and update all players via takeDamage(0) and then instead of showing enemys actual health it just shows 0.
Comment