public void createDrone(GameObject d)
 {
     Drone = d;
     Drone.transform.parent   = gameObject.transform;
     Drone.transform.position = Miner.transform.position;
     droneMovement            = Drone.GetComponent <DroneMovement>();
     droneMovement.setColor(Miner.GetComponent <Renderer>().material.color);
     Drone.GetComponent <DroneHealth>().playerInstance = gameObject;
     if (!photonView.IsMine)
     {
         droneMovement.DroneCamera.SetActive(false);
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        if (Input.GetKeyDown("q"))
        {
            pressed = true;
        }

        if (pressed && Input.GetKey("q"))
        {
            float castTime = 0f;
            if (firstDroneActivate)
            {
                //spawning drone
                castTime = 0.75f;
            }
            else if (PlayerCamera.activeInHierarchy)
            {
                //returning to spawned drone
                castTime = 0.5f;
            }
            else
            {
                //returning to player
                castTime = 0.25f;
            }

            droneCastTime += Time.deltaTime;

            if (droneCastTime > castTime)
            {
                pressed         = false;
                droneCastTime   = 0f;
                activateScripts = !activateScripts;
                if (firstDroneActivate)
                {
                    firstDroneActivate = false;
                    if (photonView.IsMine)
                    {
                        object[] data = new object[1];
                        data[0]       = photonView.ViewID;
                        Drone         = PhotonNetwork.Instantiate("DroneCamera", gameObject.transform.position, gameObject.transform.rotation, 0, data);
                        droneMovement = Drone.GetComponent <DroneMovement>();
                        droneMovement.setColor(Miner.GetComponent <Renderer>().material.color);
                    }

                    //photonView.RPC("createDrone", RpcTarget.All);

                    //Drone.transform.position = new Vector3(Miner.transform.position.x, Miner.transform.position.y + 0.5f, Miner.transform.position.z);
                    activateScripts = false;
                }

                checkScripts = true;
            }
        }
        else if (droneCastTime > 0)
        {
            droneCastTime = 0f;
        }

        if (checkScripts)
        {
            checkScripts = false;
            if (activateScripts)
            {
                PlayerCamera.SetActive(true);
                Miner.GetComponent <CustomMovementTest>().playerControl = true;
                onClickPlayer.enabled  = true;
                shootReflector.enabled = true;
                droneMovement.drone_deactivate();
            }
            else
            {
                PlayerCamera.SetActive(false);
                Miner.GetComponent <CustomMovementTest>().playerControl = false;
                onClickPlayer.enabled  = false;
                shootReflector.enabled = false;
                droneMovement.drone_activate();
            }
        }

        //bad code but it'll work
        if (Miner)
        {
            if (PlayerCamera.activeInHierarchy)
            {
                GameManager.instance.changeCrosshairUI(false);
                GameManager.instance.changePlayerHealthUI(Miner.GetComponent <PlayerHealth>());
            }
            else
            {
                GameManager.instance.changeCrosshairUI(true);
                GameManager.instance.changeDroneHealthUI(Drone.GetComponent <DroneHealth>());
            }
        }
    }