OnPlayerEnteredRoom/OnPlayerLeftRoom Methods - "No Suitable Method Found to Override"

Hello,

I'm following the tutorial for PUN v2 (https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/gamemanager-levels)

When I added this section
#region Photon Callbacks


public override void OnPlayerEnteredRoom(Player other)
{
    Debug.LogFormat("OnPlayerEnteredRoom() {0}", other.NickName); // not seen if you're the player connecting


    if (PhotonNetwork.IsMasterClient)
    {
        Debug.LogFormat("OnPlayerEnteredRoom IsMasterClient {0}", PhotonNetwork.IsMasterClient); // called before OnPlayerLeftRoom


        LoadArena();
    }
}


public override void OnPlayerLeftRoom(Player other)
{
    Debug.LogFormat("OnPlayerLeftRoom() {0}", other.NickName); // seen when other disconnects


    if (PhotonNetwork.IsMasterClient)
    {
        Debug.LogFormat("OnPlayerLeftRoom IsMasterClient {0}", PhotonNetwork.IsMasterClient); // called before OnPlayerLeftRoom


        LoadArena();
    }
}


#endregion
I get 2 errors from Visual Studio:

NetworkGameManager.cs(22,30): error CS0115: 'NetworkGameManager.OnPlayerEnteredRoom(Player)': no suitable method found to override

NetworkGameManager.cs(37,30): error CS0115: 'NetworkGameManager.OnPlayerLeftRoom(Player)': no suitable method found to override

I'm inheriting MonoBehaviourPunCallbacks in my class. What's really puzzling me is that other Callbacks, like OnLeftRoom(), are totally working.

I'm using Unity 2018.3.6f1, and VS2017. Pun: 2.7, Photon lib: 4.1.2.9.

Any ideas? I'm stumped.

Thanks!

Comments

  • Hi @Chuggsy,

    Thank you for choosing Photon!

    Make sure GameManager extends MonoBehaviourPunCallbacks.

    public class GameManager : MonoBehaviourPunCallbacks
  • ChuggsyChuggsy
    edited February 2019
    Hi @JohnTube ,

    Thanks for responding. I am extending MonoBehaviourPunCallbacks in my NetworkGameManager class.

    OnLeftRoom() and other overrides are working fine. Just these 2 are causing problems.
  • JohnTubeJohnTube mod
    edited February 2019
    Hi @Chuggsy,

    This is weird.
    I can't see how this is happening.
    Does Unity also complain about this or only Visual Studio?
    What Unity version is this?
    What PUN version is this?

    Try restarting Unity, restarting Visual Studio, new empty fresh clean project, different Unity version, re-importing PUN2...
  • Hi @JohnTube,

    I finally figured out the problem. I had a public class `Player` in the same namespace - so those methods were trying to use that class as their argument type, instead of photon.realtime's `Player`.

    Thank you for your help! That was very confusing.

    Cheers,
    Jonathan
  • Thank you @Chuggsy - I had the exact same problem.

    My GameManager class was inheriting from MonoBehaviourPunCallbacks so I couldn't figure out what was the problem. The parameter was of different (Player) type and after changing the type to Photon.Realtime.Player everything started working as expected.

    Thanks again!
  • mteaglemteagle
    edited March 21
    Milos wrote: »
    Thank you @Chuggsy - I had the exact same problem.

    My GameManager class was inheriting from MonoBehaviourPunCallbacks so I couldn't figure out what was the problem. The parameter was of different (Player) type and after changing the type to Photon.Realtime.Player everything started working as expected.

    Thanks again!


    Thanks, you helped me really. I don't know why opening a project has a problem today while it looks good every day before. Thanks again
  • Chuggsy wrote: »
    Hi @JohnTube,

    I finally figured out the problem. I had a public class `Player` in the same namespace - so those methods were trying to use that class as their argument type, instead of photon.realtime's `Player`.

    Thank you for your help! That was very confusing.

    Cheers,
    Jonathan

    @Chuggsy Man you are a life saver!!!! thanks a lot!
Sign In or Register to comment.