RPC Error
The whole answer can be found below.
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).
RPC Error
Bob19582
2021-10-19 02:49:17
I am receiving the error "RPC method 'Reduce Health' found on object with PhotonView 2099 but has wrong parameters. Implement as 'ReduceHealth(Single)' PhotonMessageInfo optional as final parameter. Return type must be void or IEnumerator (if you enable RunRpcCoroutines)"
Here is the relevant code ("SetHealth()" is called from a different script):
public void SetHealth(float health)
{
photonView.RPC("UpdateHealthBar", RpcTarget.All, health);
}
[PunRPC]
void UpdateHealthBar(float health)
{
healthBar.value = health;//updates the health bar value
fill.color = gradient.Evaluate(health);//updates the health bar colour
}
If anyone could help me that would be great.
Thanks.
Comments
[Deleted User]
2021-10-19 03:37:56
Hi, please make sure that the PhotonView is correct. Your error doesn't seem related to the piece of code you sent. ReduceHealth
is not the function you're trying to get working, yet that is what was sent in the error. Please also make sure that you have a PhotonView attached as a component, preferably use MonoBehaviourPun instead of the regular MonoBehaviour.