Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 奇怪的(Pun2)RPC问题。(在谷歌搜索中根本不会出现错误消息)_C#_Unity3d_Photon - Fatal编程技术网

C# 奇怪的(Pun2)RPC问题。(在谷歌搜索中根本不会出现错误消息)

C# 奇怪的(Pun2)RPC问题。(在谷歌搜索中根本不会出现错误消息),c#,unity3d,photon,C#,Unity3d,Photon,每次尝试使用rpc发送分数更新时,我都会遇到一个奇怪的错误 这里是错误 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.Debu

每次尝试使用rpc发送分数更新时,我都会遇到一个奇怪的错误

这里是错误

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)
下面是代码中处理玩家“死亡”的部分[from TakeDamage(),[ImpactDamage()将变量发送到TakeDamage()以更新值],并应将信息发送给其他所有玩家。(当玩家生命值为零时调用此get,它在“本地”查找时起作用)

这里是分数管理器的一部分,它更新RPC(试图)向其发送信息的分数等

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");
       }
   }
public void UpdateScores(字符串teamName,float scoreReceived)
{
if(团队名称=“SMC检索团队”)
{
pscScoreCounter-=收到的分数;
如果(pscScoreCounter=100)
{
pscScoreCounter=100;
}
}
if(团队名称==“史前生物”)
{
smcScoreCounter-=收到的分数;
如果(smcScoreCounter=100)
{
SMC计数器=100;
}
}
TXTSCMScoreCounter.text=smcScoreCounter.ToString();
smcScoreBar.sizeDelta=新向量2(smcScoreCounter*ScoreBar乘数,scoreBarHeight);

如果(smcScoreCounter)在目标对象上似乎有另一个组件,它也有一个名为
RPC_SendScore
的方法,具有相同的签名…您是否意外地添加了相同的组件两次?
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");
       }
   }