It would be really nice if my game allows people to invite to a room via discord, might be available somehow, but I don’t know how

PhotonNetwork.Instantiate()and
PhotonNetwork.Destroy()
public class Spawn : MonoBehaviourPun { //Photon using Photon.Pun; using Photon.Realtime; using ExitGames.Client.Photon; private void Spawn() { Vector3 instantPos = new Vector3(spawnVectorX, spawnVectorY, spawnVectorZ); //Instantiate accross the network (never use PUN RPC to spawn) PrefabPooler(System.IO.Path.Combine("Creep", ennemyData.ennemyGO.name), instantPos, Quaternion.identity); } //-------------------------------------------------------------------------------------------// // PHOTON PREFAB POOL // //-------------------------------------------------------------------------------------------// /// <summary> /// -CLEV- FOR PHOTON PUN2 ///An Object Pool can be used to keep and reuse instantiated object instances. ///Replaces Unity's default Instantiate and Destroy methods. ///Defaults to the DefaultPool type.To use a GameObject pool, ///implement IPunPrefabPool and assign it here. Prefabs are identified by name. /// </summary> /// /// <param name="prefabId"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <returns></returns> private GameObject PrefabPooler(string prefabId, Vector3 position_i, Quaternion rotation) { //If our pooler is not full, continue to instantiate a Warden with PUN2 if (spawnPrefabArray.Count < maxPoolSize) { ennemySpawn = PhotonNetwork.Instantiate(System.IO.Path.Combine("Creep", ennemyData.ennemyGO.name), position_i, Quaternion.identity); spawnPrefabArray.Add(ennemySpawn);//add it to the queue } //Otherwise use the Pool to activate our Wardens else { for(int i = 0; i < spawnPrefabArray.Count; i++) { if (spawnPrefabArray[i].GetComponent<LifeSystemNet>().ennemyIsDead) { Debug.Log(spawnPrefabArray[i] + " is recycled"); ennemySpawn = spawnPrefabArray[i]; ennemySpawn.GetComponent<LifeSystemNet>().ennemyIsDead = false; ennemySpawn.transform.position = position_i; ennemySpawn.SetActive(true);//activate the gameObject break; //stop the loop } } } return ennemySpawn; } }
PhotonNetwork.Destroy()
if(ennemySpawn.isDead) { ennemySpawn.SetActive(false); }
public int money; if (Input.GetKeyDown(KeyCode.F)) { PhotonView PV = GetComponent<PhotonView>(); PV.RPC("IncreaseMoney", RpcTarget.All, 5); } [PunRPC] public void IncreaseMoney(int amount) { money += amount; }
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class Player_Information : MonoBehaviourPun, IPunObservable { // Start is called before the first frame update [SerializeField] string PlayerName; [SerializeField] int PlayerPing; [SerializeField] string PlayerTeam; public Network_Character NC_Script; bool Update_Ping = true; bool Update_Info = true; void Start() { } // Update is called once per frame void Update() { if (PhotonNetwork.IsConnected && GetComponent<PhotonView>().IsMine == false) { return; } //empty name if (PlayerName.Length == 0) { Update_Name(); } if (PlayerTeam.Length == 0) { Update_Team(); } if (Update_Ping) { StartCoroutine(Update_Players_Ping()); } } void Update_Team() { if (NC_Script.IsHuman) { PlayerTeam = "Team Blue"; } else { PlayerTeam = "Team Red"; } } void Update_Name() { PlayerName = PlayerPrefs.GetString("nickname"); } IEnumerator Update_Players_Ping() { Update_Ping = false; //update ping every 3 seconds while (true) { PlayerPing = PhotonNetwork.GetPing(); yield return new WaitForSecondsRealtime(3); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) { //This is if I am sending data to the server stream.SendNext(PlayerPing); } else { // if I am not sending data to the server then I must be receiving data PlayerPing = (int)stream.ReceiveNext(); } } }
public class yoyoUlt : MonoBehaviour, IPunInstantiateMagicCallback { public float yoyoFast = 10, spinSpeed = 10, maxSpinSpeed = 10; private float scale; public Transform yoyoChild; private Vector3 playerScale; object[] instData; // Start is called before the first frame update void OnEnable() { transform.localScale = new Vector3(playerScale.x, 1, 1); scale = playerScale.x; } public void OnPhotonInstantiate(PhotonMessageInfo info) { Debug.Log("Instantiated"); instData = info.photonView.InstantiationData; playerScale = (Vector3)instData[0]; Debug.Log("inst data " + playerScale); }
object[] yoyoOwnerPlayerData = new object[1]; yoyoOwnerPlayerData[0] = DukeParent.transform.localScale; PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "YoyoUlt"), yoyoOrig.transform.position, Quaternion.identity, 0, yoyoOwnerPlayerData);
//with a raycast i interacted with the right object and now i'm and now I'm collecting the info I need to change mesh and material if (Physics.Raycast(ray, out RaycastHit hit)) { GameObject tempHit = hit.collider.gameObject; if (tempHit.GetComponent<Prop>()) { PV.RPC("RPC_PropChangeModel", RpcTarget.All, tempHit); } } [...] [PunRPC] void RPC_PropChangeModel(GameObject temp) { if (!PV.IsMine) return; gameObject.GetComponent<MeshFilter>().mesh = temp.GetComponent<MeshFilter>().mesh; gameObject.GetComponent<MeshRenderer>().material = temp.GetComponent<MeshRenderer>().material; }
public float playerCount; public void Start() { playerCount = 0f; } void Update() { if (PhotonNetwork.IsMasterClient) { if (playerCount >= GameManager.instance.playersToWin && !GameManager.instance.gameEnded) { GameManager.instance.gameEnded = true; GameManager.instance.photonView.RPC("WinGame", RpcTarget.All); } } void OnTriggerEnter(Collider other) { if (other.CompareTag("LevelEnd")) { playerCount += 1; } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext(playerCount); } else if (stream.IsReading) { playerCount = (float)stream.ReceiveNext(); } }