How do I fix "RPC method not found on object with PhotonView 1001"?

33 Views Asked by At

I followed on stackOverFlow answers to make Playing audio to all players, but when i press fire button, it shows error. Here the error : RPC method 'machineGunSound()' not found on object with PhotonView 1001. Implement as non-static. Apply [PunRPC]. Components on children are not found. Return type must be void or IEnumerator (if you enable RunRpcCoroutines). RPCs are a one-way message.

And Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using TMPro;
using Photon.Pun.UtilityScripts;
using Photon.Realtime;
public class punSoundPlayer : MonoBehaviourPunCallbacks
{
    public AudioClip machineGun;

    public AudioSource audioSource;
    public void machine()
    {
        PhotonView photonView = GetComponentInParent<PhotonView>();
        photonView.RPC("machineGunSound", RpcTarget.All);
    }

    [PunRPC]
    public void machineGunSound()
    {
        audioSource.PlayOneShot(machineGun);
    }



    
}

i tried to check [PunRPC] but it looks doesn't have any problems

0

There are 0 best solutions below