OnPlayerEnteredRoom/OnPlayerLeftRoom Methods - No Suitable Method Found to Override

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

Chuggsy
2019-02-25 00:30:27

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
2019-02-26 10:17:14

Hi @Chuggsy,

Thank you for choosing Photon!

Make sure GameManager extends MonoBehaviourPunCallbacks.

public class GameManager : MonoBehaviourPunCallbacks

Chuggsy
2019-02-26 15:05:12

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
2019-02-27 09:48:17

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
2019-02-27 17:23:49

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
2020-02-08 19:34:01

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
2020-03-21 14:33:02

@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
2020-08-02 13:11:04

@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
2020-10-15 17:29:31

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)

Luffy_Senpai
2022-12-30 03:01:13

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

Back to top