Hi all,
I'm getting a strange error every time I try to send a score update using an rpc using Photon Unity Networking (And Unity3d).
Here is the Error.
RPC method 'RPC_SendScore(String, Single)' found 2x on object with PhotonView 1201. Only one component should implement it.Return type must be void or IEnumerator (if you enable RunRpcCoroutines).
UnityEngine.Debug:LogErrorFormat (UnityEngine.Object,string,object[])
Photon.Pun.PhotonNetwork:ExecuteRpc (ExitGames.Client.Photon.Hashtable,Photon.Realtime.Player) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:651)
Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,Photon.Realtime.Player,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1275)
Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2847)
Photon.Pun.PhotonView:RPC (string,Photon.Pun.RpcTarget,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:678)
SubHealthManager:SubDeath () (at Assets/_Scripts/PlayerControllers/SubHealthManager.cs:141)
SubHealthManager:TakeDamage (single) (at Assets/_Scripts/PlayerControllers/SubHealthManager.cs:116)
SubHealthManager:ImpactDamage (UnityEngine.Collision) (at Assets/_Scripts/PlayerControllers/SubHealthManager.cs:100)
SubHealthManager:OnCollisionEnter (UnityEngine.Collision) (at Assets/_Scripts/PlayerControllers/SubHealthManager.cs:88)
Here is the section of the code that deals with the 'death' - from TakeDamage(), ImpactDamage() sends variable to TakeDamage() to update the values of the player and supposed to send the information to every other player. (This get's called when the player health hits zero, it works find 'locally')
public void SubDeath()
{
float damage = 5f;
rbGravity.useGravity = true;
playerControllerMK.SetActive(false);
playerControllerController.SetActive(false);
playerFiringController.SetActive(false);
adjustedOverLoad = (overloadCounter * overloadRecoveryTime);
isDead = true;
//ScoringManager.Instance.UpdateScores(teamName, damage);
if (PV.IsMine)
{
Debug.Log("PV Is Mine, I should send S*** now");
PV.RPC("RPC_SendScore", RpcTarget.All, teamName, damage);
}
}
[PunRPC]
void RPC_SendScore(string teamName, float damage)
{
ScoringManager.Instance.UpdateScores(teamName, damage);
}
And here is the section of the Score Manager which updates the scores etc. that the RPC is (trying) to send information to.
[
public void UpdateScores(string teamName, float scoreReceived)
{
if(teamName == "SMC Retrieval Team")
{
pscScoreCounter -= scoreReceived;
if (pscScoreCounter <= 0)
{
pscScoreCounter = 0;
}
if (pscScoreCounter >= 100)
{
pscScoreCounter = 100;
}
}
if(teamName == "Prehistoric Creatures")
{
smcScoreCounter -= scoreReceived;
if (smcScoreCounter <= 0)
{
smcScoreCounter = 0;
}
if (smcScoreCounter >= 100)
{
smcScoreCounter = 100;
}
}
txtSMCScoreCounter.text = smcScoreCounter.ToString();
smcScoreBar.sizeDelta = new Vector2(smcScoreCounter * scoreBarMultiplier, scoreBarHeight);
if (smcScoreCounter <= 0)
{
WinCondition("Prehistoric Creatures");
}
txtPSCScoreCounter.text = pscScoreCounter.ToString();
pscScoreBar.sizeDelta = new Vector2(pscScoreCounter * scoreBarMultiplier, scoreBarHeight);
if (pscScoreCounter <= 0)
{
WinCondition("SMC Retrieval Team");
}
}
]
I'm not really sure what's going on, but based on the error, it seems as though PUN is saying that there are two objects trying to trigger the same RPC at the same time? (not entirely sure sure though).
I get the error when there is just one player in the game as well as multiple.
Could anyone shed some light please?
Thanks
Spud