PunRPC methods are not working after updating PUN 2

I've recently updated my PUN 2 package from asset store to fix a problem which was not getting userIDs when a player entered/left a room. (OnPlayerEnteredRoom callback)

The solution was to update the PUN 2 to newer versions on this forum topic.


After updating the PUN 2 plugin, all the PunRPC tagged methods started giving an error.


The PunRPC methods that worked before I updated are now throwing this error at me. Weirdest part is, they are giving this error even when I don't call these methods named "Fire" and "SpawnBossTrigger" because these methods are from another Scene which is not even loaded yet. I'm on Menu scene, these methods are from the Ingame Scene. And the actual method I'm calling is this:

[PunRPC]
public void CheckIfPartyLeader()
{
    if (PhotonNetwork.LocalPlayer.IsMasterClient)
    {
        SetPartyLeader(PlayerContainer.Shared.playerProfile.nickname);
        StorePartyLeaderIDLocally(PlayerContainer.Shared.playerProfile.nickname);
        PlayerContainer.Shared.isPartyLeader = true;
        
        gameObject.GetComponent<PhotonView>().RPC("SetPartyLeader", RpcTarget.OthersBuffered,
            PlayerContainer.Shared.playerProfile.nickname);
        gameObject.GetComponent<PhotonView>().RPC("StorePartyLeaderIDLocally", RpcTarget.OthersBuffered,
            PlayerContainer.Shared.playerProfile.nickname);
    }
}

Which is used to set the party leader in a room. I don't get whats wrong. This is from my PartyManager script. And it has a Photon View component attached to it as well.


[PunRPC]
public void KickPartyMember(string userID)
{
    Debug.Log("KickPartyMember function worked.");
    if (PhotonNetwork.LocalPlayer.UserId == userID)
    {
        Debug.Log("You're kicked from the party.");
        LeaveParty();
    }
}

[PunRPC]
public void KickButtonMethod(string userID)
{
    Photon.Realtime.Player kickTarget = null;
    foreach (var player in PhotonNetwork.CurrentRoom.Players)
    {
        if (player.Value.UserId == userID)
        {
            kickTarget = player.Value;
            break;
        }
    }

    if (kickTarget != null)
    {
        gameObject.GetComponent<PhotonView>().RPC("KickPartyMember", kickTarget , userID);
        Debug.Log("Kick Button worked.");
    }
    else
    {
        Debug.Log("KickTarget is null.");
    }
}

This is the kick function, which gives the same error but with another PunRPC method's name from another scene.


Here is the Photon View component attached to same game object with the script. And this function is non-static and in no way related to "SpawnBossTrigger" or "Fire" PunRPCs. This error appears whenever I call these CheckIfPartyLeader or KickPartyMember RPC methods.


Any ideas on what I'm missing?


Sorry for the long post, thank you for reading.

- Laranthir

Comments