OnPlayerEnteredRoom( Player newplayer ) not working

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( Player newplayer ) not working

Shimagurat
2020-02-06 15:58:54

using Photon.Pun;  
using Photon.Realtime;  
using System.Collections;  
using System.Collections.Generic;  
using UnityEngine;  
using UnityEngine.UI;  
public class RoomCreation : MonoBehaviourPunCallbacks  
{  
   public void createRoom(string roomName)  
   {  
        RoomOptions roomOps = new RoomOptions(){IsVisible = true,IsOpen = true, MaxPlayers = (byte) 4,PublishUserId = true};  
        PhotonNetwork.JoinOrCreateRoom(roomName,roomOps,TypedLobby.Default);  
    }  
   public override void OnPlayerEnteredRoom(Player newPlayer)  
   {  
       Debug.Log("player join");  
       Debug.Log(newPlayer.ToStringFull());  
   }  
   public void leave()  
   {  
       PhotonNetwork.LeaveRoom();  
   }  
   public override void OnPlayerLeftRoom(Player otherPlayer)  
   {      
       Debug.Log("player left");  
   }

this is my code i dont know why both OnPlayerEnteredRoom & OnPlayerLeftRoom is not working for me

other function is working thank you for your help :)

Comments

JohnTube
2020-02-06 17:13:38

Hi @Shimagurat,

Thank you for choosing Photon!

OnPlayerEnteredRoom & OnPlayerEnteredRoom are for remote players not for the local player.
The local player has OnJoinedRoom & OnLeftRoom callbacks.

In case you still don't get those even for the remote players then make sure to check the Matchmaking Checklist are probably players are joined to different rooms either because different AppVersion or different Region.

Or maybe you did not even join any room as not connected yet.

Shimagurat
2020-02-07 08:29:26

Hi Thank you for the answer already solved the problem that they are on different Region so that is why it is now working thank you

g4mv16
2023-02-22 11:33:47

Hi,i have tha same problem,how did you solve that?,all the connection to the servers works but onPlayerEnteredRoom and OnPlayerLeftRoom don't work

GvNiK
2023-02-24 15:28:27

I am facing the same issue with "OnPlayerEnteredRoom" not wotking. Rest all the functions work correctly.

g4mv16 2023-02-22T11:33:47+00:00

Hi,i have tha same problem,how did you solve that?,all the connection to the servers works but onPlayerEnteredRoom and OnPlayerLeftRoom don't work

I have an old project which I made in May 2022, there "OnPlayerEnteredRoom" worked fine. I guess they might have updated the API or something.

g4mv16
2023-02-25 09:03:03

GvNiK 2023-02-24T15:28:27+00:00

I am facing the same issue with "OnPlayerEnteredRoom" not wotking. Rest all the functions work correctly.

https://forum.photonengine.com/discussion/comment/63141#Comment_63141

I have an old project which I made in May 2022, there "OnPlayerEnteredRoom" worked fine. I guess they might have updated the API or something.

My problem was that in the method "OnEnable" i hadn't called base.OnEnable

Tobias
2023-02-28 09:14:33

Depending on how old your project was, maybe you didn't register for getting callbacks in the very old versions. You need to do that now!

Back to top