- Home /
Question by
Endertech · Feb 28, 2020 at 11:53 PM ·
multiplayer-networking
Every time the scene changes I cannot see other players, is the set up wrong? (PUN 2) Thanks in advance.
public void Start()
{
lobbyMenu.enabled = false;
PhotonNetwork.AutomaticallySyncScene = true;
Connecting();
}
public void Update()
{
player_Count.text = "Players in lobby: " + PhotonNetwork.CurrentRoom.PlayerCount.ToString();
StartGame();
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected");
base.OnConnectedToMaster();
}
public override void OnJoinedRoom()
{
print("Joined room: " + roomName.text.ToString());
base.OnJoinedRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("There may be no rooms currently");
base.OnJoinRandomFailed(returnCode, message);
}
public override void OnJoinedLobby()
{
base.OnJoinedLobby();
}
public void Connecting()
{
Debug.Log("Trying to Connect");
PhotonNetwork.GameVersion = "0.0.0";
PhotonNetwork.ConnectUsingSettings();
}
public void Join()
{
PhotonNetwork.JoinRoom(roomName.text.ToString());
MainMenuToLobby();
room_Name.text = "Room Name: " + roomName.text.ToString();
}
public void JoinRandomRoom()
{
PhotonNetwork.JoinRandomRoom();
room_Name.text = "Room Name: " + roomName.text.ToString();
}
public void Create()
{
PhotonNetwork.CreateRoom(roomName.text.ToString());
print(roomName.text.ToString() + " was created");
MainMenuToLobby();
room_Name.text = "Room Name: " + roomName.text.ToString();
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
base.OnCreateRoomFailed(returnCode, message);
}
public void MainMenuToLobby()
{
mainMenu.enabled = false;
lobbyMenu.enabled = true;
}
public void JoinARoom()
{
RoomOptions roomOptions = new RoomOptions();
PhotonNetwork.JoinOrCreateRoom(roomName.text.ToString(), roomOptions, TypedLobby.Default);
room_Name.text = "Room Name: " + roomName.text.ToString();
MainMenuToLobby();
}
public void Spawn()
{
//PhotonNetwork.Instantiate(spawnObject, new Vector3(0, 0, 0), Quaternion.identity);
PhotonNetwork.Instantiate(player_prefab, new Vector3(10, 10, 10), Quaternion.identity);
}
public void StartGame()
{
if(PhotonNetwork.CurrentRoom.PlayerCount > 1)
PhotonNetwork.LoadLevel(1);
Spawn();
}
}
}
Comment