Problem Calling an RPC

I'm creating a multiplayer app in Unity using PUN2. Can anyone explain why I'm getting the following message in the Console?: PhotonView with ID 1 has no (non-static) method "StartMusicWithDelay" marked with the [PunRPC](C#) or @PunRPC(JS) property! Args: Double, Double

The following code is on a game object with a PhotonView component in the scene:
public override void OnPlayerEnteredRoom(Player newPlayer)
        gameObject.GetComponent<PhotonView>().RPC("StartMusicWithDelay", RpcTarget.AllBuffered, startTimeFirst, hostDSP);
The following code is on the player prefab, which has a PhotonView component:
    void StartMusicWithDelay(double _startTimeFirst, double _hostDSP)
        double hostMachineTime = _hostDSP + 1;
        double localStartTime = AudioSettings.dspTime + 1;
        double timeSinceStart = (_hostDSP - _startTimeFirst) % clipLength;
        int samplePosition = (int)(sampleRate * timeSinceStart);
        audioSource.timeSamples = samplePosition;
        Debug.Log("StartMusicWithDelay was called.  _hostDSP = "+ _hostDSP+". _startTimeFirst = "+_startTimeFirst);

Best Answer


  • Thanks for getting back to me, @JohnTube. I moved the first code shown above (previously in a scene object script) to the same script the second code is on (player prefab). The "StartMusicWithDelay" RPC is now called.
Sign In or Register to comment.