Hi.
I am trying to make a multiplayer game in PUN, and it was going well until now. I have an issue when trying to instantiate players. I do use PhotonNetworking.Instantiate, but for some reason, when someone joins the scene the newly joined player cannot see the first player, but the first player can see the new player. I also get the warning:
Received OnSerialization for view ID 1001. We have no such PhotonView! Ignored this if you’re leaving a room. State: Joined
I have 2 scenes; one called LobbyMenu and another called Game.
The script in the lobby:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Launcher : Photon.MonoBehaviour
{
const string VERSION = “1”;
public string roomName = “iskrem”;
public string playerName;
public Text input;
public Text nameInput;
public GameObject connect;
public GameObject roomInfo;
public GameObject NameInput;
void Start()
{
PhotonNetwork.ConnectUsingSettings(VERSION);
roomInfo.SetActive(false);
NameInput.SetActive(false);
connect.SetActive(true);
}
void OnGUI()
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
public void ConnectToRoom()
{
roomName = input.text;
OnJoinedLobby();
}
public void Spawn()
{
PhotonNetwork.isMessageQueueRunning = false;
PhotonNetwork.LoadLevel(1);
}
void OnLevelWasLoaded(int level)
{
PhotonNetwork.isMessageQueueRunning = true;
}
public void NameSelected()
{
playerName = nameInput.text;
roomInfo.SetActive(true);
NameInput.SetActive(false);
}
void OnJoinedLobby()
{
RoomOptions roomOptions = new RoomOptions() { IsVisible = false, MaxPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
print(“Successfully Joined or Created” + roomName);
}
void OnJoinedRoom()
{
NameInput.SetActive(true);
connect.SetActive(false);
}
}
I also have a GameManager script witch is in the Game scene:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class GameManager : Photon.MonoBehaviour {
public string playerPrefabName = “FPSController”;
public Transform SpawnPoint;
void Start()
{
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.Instantiate(playerPrefabName, SpawnPoint.position, SpawnPoint.rotation, 0);
}
public void OnLeftRoom()
{
SceneManager.LoadScene(0);
}
public void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
}
}
Please help me.