Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Unity [PUN] New Instantiated players cannot see previously instantiated players

$
0
0
Hello, i have recently worked on a game, but now i have this error where a new instantiated player cannot see previously instantiated players, but previously instantiated players can see newly instantiated players. There are also no error messages or warning messages in the console, though i got some previously that just magically dissapeared. It was something like failed to (something) on serilization with id 1001 ignore this if you are leaving a server. I have 2 scenes, one called LobbyMenu and one called Game. This script is mounted 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() { if (PlayerManager.LocalPlayerInstance == null) { GameObject pl = PhotonNetwork.Instantiate(playerPrefabName, SpawnPoint.position, SpawnPoint.rotation, 0) as GameObject; } } public void OnLeftRoom() { SceneManager.LoadScene(0); } public void LeaveRoom() { PhotonNetwork.LeaveRoom(); } } This second script is mounted in the LobbyMenu scene: 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 ChangeRoom(int value) { if(value == 0) { roomName = "server 1"; } else { value = 0; } } public void RoomSelect() { OnJoinedLobby(); } public void ConnectToRoom() { roomName = input.text; OnJoinedLobby(); } public void Spawn() { PhotonNetwork.LoadLevel(1); } 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); } } This last script is mounted on my player: using UnityEngine; using System.Collections; using UnityStandardAssets.Characters.FirstPerson; public class PlayerManager : Photon.MonoBehaviour { public GameObject Camera; public static GameObject LocalPlayerInstance; public void Awake() { // #Important // used in GameManager.cs: we keep track of the localPlayer instance to prevent instanciation when levels are synchronized if (photonView.isMine) { LocalPlayerInstance = gameObject; } // #Critical // we flag as don't destroy on load so that instance survives level synchronization, thus giving a seamless experience when levels load. DontDestroyOnLoad(gameObject); } void Start () { if (!photonView.isMine) { Camera.SetActive(false); GetComponent().enabled = false; } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>