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

Options
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

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Chuggsy,

    Thank you for choosing Photon!

    Make sure GameManager extends MonoBehaviourPunCallbacks.

    public class GameManager : MonoBehaviourPunCallbacks
  • Chuggsy
    Chuggsy
    edited February 2019
    Options
    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.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2019
    Options
    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...
  • Chuggsy
    Options
    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
  • Milos
    Options
    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!
  • mteagle
    mteagle
    edited March 2020
    Options
    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
  • Pranjal
    Options
    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!
  • m4trixlol
    Options
    I am getting the same problem but I made sure that I haven't done the same mistake, and it still says it.
    What can I do to fix it? (im also following a tutorial on pun2 and for the dude he had no prblom)
  • using pun 2 following tutorial for fps multiplayer game and it says "Assets\Scripts\Launcher.cs(59,48): error CS0246: The type or namespace name 'RoomInfo' could not be found (are you missing a using directive or an assembly reference?)" is there something wrong with my script? or what? please help me