Search Unity

Third Party Error in pun2: RPC method '_SendMessege(String)' not found on object with PhotonView 1001

Discussion in 'Multiplayer' started by trmhtk2_unity, Apr 15, 2021.

  1. trmhtk2_unity

    trmhtk2_unity

    Joined:
    Mar 29, 2020
    Posts:
    35
    Hello everyone, I recently wanted to make a system of speech bubbles in multiplayer with the help of Pun2 and the following error was discovered:
    Code (CSharp):
    1. RPC method '_SendMessege(String)' not found on object with PhotonView 1001. Implement as non-static. Apply [PunRPC]. Components on children are not found.
    2. UnityEngine.Debug:LogErrorFormat (UnityEngine.Object,string,object[])
    3. Photon.Pun.PhotonNetwork:ExecuteRpc (ExitGames.Client.Photon.Hashtable,Photon.Realtime.Player) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:627)
    4. Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,Photon.Realtime.Player,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1236)
    5. Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2812)
    6. Photon.Pun.PhotonView:RPC (string,Photon.Pun.RpcTarget,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:792)
    7. Photon.Pun.MessegeManger:SendMessege () (at Assets/Code/MessegeManger.cs:41)
    8. UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)
    9.  
    Here is the code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    5. using Photon.Pun;
    6. using Photon.Realtime;
    7. using UnityEngine.UI;
    8. using Photon.Chat;
    9.  
    10.  
    11. namespace Photon.Pun
    12. {
    13.     public class MessegeManger : MonoBehaviourPun
    14.     {
    15.    
    16.         float CountDown;
    17.         public float DestroyDealySeconds = 3f;
    18.         public string Messege;
    19.         public player plMove;
    20.         public PhotonView photonView;
    21.         [SerializeField] GameObject BubbleSpeechText;
    22.         [SerializeField] TMP_Text UpdatedText;
    23.         public int MaxLimit = 50;
    24.         [SerializeField] TMP_InputField ChatInputFieald;
    25.         private bool DisableSend;
    26.         private void Start()
    27.         {
    28.             BubbleSpeechText = GameObject.Find("Chat Bubble");
    29.             UpdatedText = GameObject.Find("ChatBubbleText").GetComponent<TMP_Text>();
    30.             //ChatInputFieald = GameObject.FindGameObjectWithTag("ChatInput").GetComponent<TMP_InputField>();
    31.             BubbleSpeechText.SetActive(false);
    32.             CountDown = DestroyDealySeconds;
    33.             ChatInputFieald.characterLimit = MaxLimit;
    34.         }
    35.         [PunRPC]
    36.  
    37.         public void SendMessege()
    38.         {
    39.             if (photonView.IsMine)
    40.             {
    41.                 photonView.RPC("_SendMessege", RpcTarget.AllBuffered,ChatInputFieald.text);
    42.             }
    43.  
    44.         }
    45.         void _SendMessege()
    46.         {  
    47.             //if (!photonView.IsMine)       {   return; }
    48.             CountDown = DestroyDealySeconds;
    49.             Messege = ChatInputFieald.text;
    50.        
    51.             ChatInputFieald.text = "";
    52.         }
    53.         private void Update()
    54.         {
    55.            CountDown -= Time.deltaTime;
    56.             if(CountDown <= 0) {      Messege = "";   }
    57.             if(Messege == "")
    58.             {
    59.                 BubbleSpeechText.SetActive(false);
    60.             } else { BubbleSpeechText.SetActive(true); }
    61.             UpdatedText.text = Messege;
    62.         }
    63.    
    64.     }
    65.    
    66. }
    67.  
    Please answer me quickly it is very important to me!
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Well, the error tries to help you figure it out.
    "RPC method '_SendMessege(String)' not found on object" means the RPC is received but no component on the target has the method to be called.
    "Apply [PunRPC]." means the method you try to call via RPC needs the attribute.

    In your case, the calling method has the attribute but the "_SendMessege" doesn't.
     
    goldcloud144 likes this.
  3. adgames2018

    adgames2018

    Joined:
    Dec 4, 2021
    Posts:
    1
    change location [PunRPC] above void _SendMessege(){...}