I can see them, but they can't

Options
Hello everyone,
I have a problem right here.
Basically, if I spawn in first place, I will see everybody, but if I spawn in second or third place (or even higher), I can't see anyone that spawned before me, I can only see everybody that spawns after me.
void Start(){
		SpawnPlayer ();
		if(!IsDebug){
			foreach(PhotonPlayer P in PhotonNetwork.otherPlayers){
				if(P.name != PhotonNetwork.playerName){
					Team = P.GetTeam();

					
					if(Team.ToString() == "red"){
						SpawnRand = UnityEngine.Random.Range (0, Alphasite.Length);
						PlayerGO = ((GameObject)PhotonNetwork.Instantiate ("Soldier_1", new Vector3(0,0,0),Quaternion.identity,0));
						PlayerGO.name = PlayerGO.GetComponent<PhotonView>().owner.name;
						TempTeam = "A";
					}else if(Team.ToString() == "blue"){
						SpawnRand = UnityEngine.Random.Range (0, Bravosite.Length);
						PlayerGO = ((GameObject)PhotonNetwork.Instantiate ("Soldier_1", new Vector3(0,0,0),Quaternion.identity,0));
						PlayerGO.name = PlayerGO.GetComponent<PhotonView>().owner.name;
						TempTeam = "B";
					}


					if(TempTeam == myplayer.GetComponentInChildren<PlayerInfos>().GetT ()){
						PlayerGO.transform.FindChild ("PlayerName").GetComponent<TextMesh>().text = PlayerGO.GetComponent<PhotonView>().name;
						PlayerGO.transform.FindChild ("PlayerName").gameObject.SetActive (true);
					}else if(TempTeam != myplayer.GetComponentInChildren<PlayerInfos>().GetT ()){
						PlayerGO.transform.FindChild ("PlayerName").GetComponent<TextMesh>().text = PlayerGO.GetComponent<PhotonView>().name;
						PlayerGO.transform.FindChild ("PlayerName").gameObject.SetActive (false);
						Debug.Log (myplayer.GetComponentInChildren<PlayerInfos>().GetT ());
					}
					(PlayerGO.transform.FindChild ("Main Camera").GetComponent<Camera>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<PlayerInfos>()).enabled = false;
					PlayerGO.transform.FindChild ("Main Camera").GetComponent<OtherPlayerInfos>().enabled = true;
					PlayerGO.transform.FindChild ("Main Camera").GetComponent<OtherPlayerInfos>().SetInfos (PlayerGO.GetComponent<PhotonView>().owner.name,100,0, TempTeam);
					((MonoBehaviour)PlayerGO.GetComponentInChildren<PlayerRaycastShowname>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<FPSInputController>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<MouseLook>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<MouseLook>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<SprintAndCrouch>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<ShootPlayer_UZI>()).enabled = false;
					(PlayerGO.GetComponentInChildren<AudioListener>()).enabled = false;
					((MonoBehaviour)PlayerGO.GetComponentInChildren<GameManager>()).enabled = false;
					PlayerGO.gameObject.SetActive (true);
				}
			}
		}
	}


Is there a way to correct this?
Thanks,
PeterAS17

Comments

  • an RPC? RPC target OR ??
  • No, I have no RPC... I don't understand how it works, so I tried to go around.
  • vadim
    Options
    Hi,

    It's hard to guess from your report what you are spawning.
    Common practice is spawning things with PhotonNetwork.Instantiate method from prefab with PhotonView attached. Check PUN demos and Marco Polo tutorial
  • Yes, I'm using PhotonNetwork.Instantiate to spawn objects and players, but people that are there before me don't spawn for me.
  • vadim
    Options
    Any errors or warnings in console? When PhotonNetwork.Instantiate is called?
  • No, there's absolutely no errors...!
  • but if I spawn in second or third place (or even higher), I can't see anyone that spawned before me, I can only see everybody that spawns after me.

    the problem is?
  • I think it's very explicit...! xD
    Basically:
    Player 1 = X
    Player 2 = Y
    Player 3 = Z

    X spawns.
    Y spawns.
    Z spawns.

    X can see Y and Z.
    Y can see Z but not X.
    Z can't see neither Y nor X.
  • vadim
    Options
    vadim wrote:
    When PhotonNetwork.Instantiate is called?
  • yeah..send the your codes
  • It's called when the player joins the room...
    EDIT: Added code to the first post.
  • Bump
  • vadim
    Options
    When do Start() get called?
    What does SpawnPlayer() do?
    Why not to try more simple span scheme w/o groups at first. After you make sure that it works, switch to something more complicated.
    In general it looks quite strange that you instantiate player for each player in list. Usually one PhotonView.Instantiate() call per client required.
  • It is called after the player joins the room and loads the level.
    And SpawnPlayer() spawns a player...
    I'll try to make it more simple to test then.
  • This happened to me once, you need to stop the buffered messages until you are in the level, add "PhotonNetwork.isMessageQueueRunning = false;" to void OnJoinedRoom() then run "PhotonNetwork.isMessageQueueRunning = true;" when you are in the level (put it in awake some where).

    This happends because when you load a level all the buffered messages that are sent to the player joinning the room are lost when you load a new scene so the information about the instantiated objects is also lost.