public void Start()
{
PV = GetComponent<PhotonView>();
playerID = Random.Range(0, GameSetUp.GS.spawnPoints.Length);
if (PV.IsMine)
{
myUnit = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "UnitAvatar"),
GameSetUp.GS.spawnPoints[playerID].position,
GameSetUp.GS.spawnPoints[playerID].rotation, 0);
PV.RPC(nameof(RPC_NewUnit),
RpcTarget.AllBuffered,
myUnit.GetComponent().ViewID,
playerID);
}
}
[PunRPC]
public void RPC_NewUnit(int ViewID, int PlayerID)
{
GameObject unit = PhotonView.Find(ViewID).gameObject;
unit.tag = PlayerID;
}
public class Сontroller : MonoBehaviour
{
public List<GameObject> selectGroup = new List<GameObject>();
public List<GameObject> Group = new List<GameObject>();
public void Update()
{
foreach (GameObject tmp in Group)
{
if (tmp is MissingReferenceException)
{
Group.Remove(tmp);
}
}
}
}
LayerMask mask = LayerMask.GetMask("Earth");
if (Physics.Raycast(_ray, out _hit, 500f, mask))
//etc