2022-06-28

Why doesn't OnPlayerEnteredRoom() method work?

i make room in unity with photon pun. When i join the room, OnPlayerEnteredRoom() doesn't get call. MonoBehaviourPunCallbacks and IInRoomCalbacks already inherited. Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
public class RoomServer : MonoBehaviourPunCallbacks, IInRoomCallbacks
{
public TMP_Text p1, p2, p3, p4;
public Sprite p1i, p2i, p3i, p4i;
public Sprite p1is, p2is, p3is, p4is;
public GameObject playerPrefab;
// Start is called before the first frame update
void Start()
{
    PhotonNetwork.AutomaticallySyncScene = true;
    Debug.Log("ao");
}

// Update is called once per frame
void Update()
{
    
}
public void OnPlayerEnteredRoom() {
    PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0,0,0), Quaternion.identity);
    Debug.Log("Player has joined!");
}
public void OnPlayerLeftRoom(Player newPlayer) {

}
public void OnRoomPropertiesUpdate(Hashtable hashtable) {
    
}
public void OnMasterClientSwitched(Player newPlayer) {

}
public void OnPlayerPropertiesUpdate(Player newPlayer, Hashtable hashtable) {

}

}



No comments:

Post a Comment