- Home /
Question by
SPOTNINJADUD7890 · Oct 09, 2016 at 09:41 AM ·
c#networkingmultiplayerunity5multiplayer-networking
How to synchronize disable and enabling game objects over the network?
I need to know if anyone can figure out if i could synchronize the 2 weapons switched being enabled and disabled over the network.My thought was an RPC call if that is the case tell me.lastly i am unity photonnetwork But a unity network solution i can translate myself into photonnetwork.
heres code
using UnityEngine;
using System.Collections;
public class wepSwitcher : MonoBehaviour {
public GameObject[] weps;
void Awake(){
changeWep (0);
}
void Update(){
if(Input.GetKeyDown (KeyCode.Alpha1)){
changeWep (0);
}
if(Input.GetKeyDown (KeyCode.Alpha2)){
changeWep (1);
}
}
public void changeWep(int seq){
disableAll ();
weps [seq].SetActive (true);
}
public void disableAll(){
foreach (GameObject wep in weps) {
wep.SetActive (false);
}
}
}
Comment