- Home /
 
               Question by 
               casteponters · Feb 17, 2015 at 05:47 PM · 
                c#networkingphotonsetactive  
              
 
              Photon - Hide/Show Object
I need to show or hide my gun. But in other client is not updated, and a strange thing happens. I am attaching the image.
When I hide the object, but it continues to remain detached from the player. 
and this is my code:
Go.cs
 //ShotGun
     private bool show_gun;
     public GameObject Gun;
 
     
     // Use this for initialization
     void Start () {
 
         show_gun = false;
             
     }
     
     // Update is called once per frame
     void Update () {
 
         if (Input.GetKey ("a")) {
             hspeed = -RUN;
         } else if (Input.GetKey ("d")) {
             hspeed = RUN;
         } else {
             hspeed = 0;
         }
         
         
         if (Input.GetKeyDown ("w")) {
             //Controllo se collide con il terrento e se posso eseguire il doppio salto
             vspeed = JUMP_SPEED;
         } else {
             vspeed = 0;
         }
         
         rigidbody2D.velocity = new Vector3 (hspeed, vspeed + rigidbody2D.velocity.y, 0);
 
 
 
 
         if (photonView.isMine) 
         {
             //??
             
         }else{
             
             if (show_gun == false) {
                 Gun.SetActive(false);
             } else {
                 Gun.SetActive(true);
             }
             
         }
 
 
 
 
         if (Input.GetMouseButtonDown (1)) {
             //Nascondo arma
             if(show_gun == true){
                 Gun.SetActive(false);
                 show_gun = false;
             }else{
                 Gun.SetActive(true);
                 show_gun = true;
             }
 
         }
         
     }
 
 
     void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
         if(stream.isWriting){
             stream.SendNext(show_gun);
         }else{
             show_gun = (bool)stream.ReceiveNext();
         }
     }
 
                 
                error.jpg 
                (37.2 kB) 
               
 
              
               Comment
              
 
               
              Answer by SwedishDerp · Mar 21, 2015 at 07:52 PM
I believe you have to make an RPC to hide/show the gun. That's the way i did it. Btw, the game looks awesome!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                