- Home /
Spawn point for specific player.Photon Pun2
Hi! i used this code to spawn my specific player at specific spawn point.when player leave room i want to able to spawn new player at spawn point that was available by player that left, and i used PlayerNumbering but it didn't work ,it shows that my number of localplayer is 0 ,but actually it's 1 in switchchat class.It makes spawn each player at one same spawn point. Do you have any suggestions or solutions? using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Realtime; using Photon.Pun; using ExitGames.Client.Photon; using UnityEngine.SceneManagement; using Photon.Pun.UtilityScripts;
public class switchchar : MonoBehaviourPunCallbacks { [SerializeField] GameObject[] SpawnPoints; [SerializeField] GameObject blacktran; [Space(20f)]
 public GameObject default_gg;
 [SerializeField] private GameObject camouflage_gg;
 [SerializeField] private GameObject angel_gg;
 [SerializeField] private GameObject tiger_gg;
 [SerializeField] private GameObject devil_gg;
 public static GameObject pl;
 
 
 public static int localPlayerIndex;
 private bool isLocalPlayerIndexSet { get { return localPlayerIndex >= 0; } }
 
 public override void OnEnable() {
     base.OnEnable();
     PlayerNumbering.OnPlayerNumberingChanged += OnPlayerNumberingChanged;
 
 } 
 public override void OnDisable() {
     base.OnDisable();
     PlayerNumbering.OnPlayerNumberingChanged -= OnPlayerNumberingChanged;
 }
 private IEnumerator Start() {
     while (!isLocalPlayerIndexSet) {
         yield return null;
     }
     Debug.Log(switchchar.localPlayerIndex + " local");
     NetworkInstantiation();
 }
 private void OnPlayerNumberingChanged() {
     if (!isLocalPlayerIndexSet) {
         localPlayerIndex = PhotonNetwork.LocalPlayer.GetPlayerNumber();
        
     }
     
 }
 
 void NetworkInstantiation() {
    
     
     if (isLocalPlayerIndexSet) {
         if (imagespr.ine == 0) 
             pl = MasterManager.NetworkingInstantiate(default_gg, SpawnPoints[localPlayerIndex].transform.position, Quaternion.identity);
             pl.transform.SetSiblingIndex(1);
     }
 }
   
 }
 
}
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                