[英]Why Calling An RPC Function With An Integer Parameter Gives Error? -Photon Unity
I am Using Photon 2 And I Have Public Rpc Function In One Of My Script, The Function Has An Integer Parameter, This Is How My Function Exactly Looks Like.我正在使用 Photon 2,并且在我的一个脚本中有公共 Rpc 函数,该函数有一个整数参数,这就是我的函数的样子。
[PunRPC]
public void TakeDamage(int amount)
{
playerHealth -= amount;
if (playerHealth <= 0)
{
Debug.Log("Player Died");
}
}
We In Above Code The TakeDamage Function Takes An Integer Called amount.我们在上面的代码中 TakeDamage 函数采用一个整数调用量。 So When I am Calling This Function From Other Scripts, And When The Other scripts Actually Call The Function It Gives A Warning.
因此,当我从其他脚本调用此函数时,当其他脚本实际调用该函数时,它会发出警告。
PV.RPC("currentTarget.TakeDamage", RpcTarget.AllBuffered, damage);
The PV is a public PhotonView. PV 是一个公共 PhotonView。
RPC method 'currentTarget.TakeDamage(Int32)' not found on object with PhotonView 1003. Implement as non-static. Apply [PunRPC]. Components on children are not found.
您必须在 RPC 函数中给出函数名称("TakeDamage")
而不是"currentTarget.TakeDamage"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.