Problem with sending RPC

Options
I have a script which plays audio and I would like to send this to other clients. My problem is an error which states that the PhotonView has no method "PlayAudio" marked with [PunRPC]. Here is my PlayAudio method which is marked with that tag:

[PunRPC]
public void PlayAudio(string clipName)
{
Audio_Manager.Instance.PlayAudioClip(clipName, audioSource);
}

Here is the method where I call PlayAudio():

public void PlayJumpAudio()
{
photonView.RPC("PlayAudio", RpcTarget.All, jumpAudio);
}

I will also mention that this script is on the same object as the PhotonView, and I do actually remove this component from other clients for the local player since it seemed unnecessary to have scripts on other clients which won't be used locally. Could this be the cause of the problem? Just to clarify, it is being removed on other clients locally only - every client still has their own version of this script.

Answers

  • Kurtis
    Options
    Never mind, it turns out I do need to have the audio source and audio controller script active on all clients, I can't just remove them on other players locally. It's just a case of leaving the scripts on all players which need to send an RPC.