Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        horRot.position  = varRot.transform.position;
        horRot.position += new Vector3(0, 1, 0);

        float X_Rotation = Input.GetAxis("Mouse X");
        float Y_Rotation = Input.GetAxis("Mouse Y");

        rotX += Y_Rotation * rot;
        rotY -= X_Rotation * rot;

        rotX = Mathf.Clamp(rotX, -90.0f, 90.0f);
        while (rotY < 0.0f)
        {
            rotY += 360.0f;
        }
        while (rotY > 360.0f)
        {
            rotY -= 360.0f;
        }

        horRot.transform.eulerAngles = new Vector3(-rotX, -rotY, 0);
        varRot.transform.eulerAngles = new Vector3(0, -rotY, 0);

        if (Input.GetMouseButton(1))
        {
            rot = ADSSpeed;
            scope.ADS(this.transform.forward);
        }
        else
        {
            rot            = rotSpeed;
            scopeObj.color = new Color(1, 1, 1, 0);
            SR.SetActive(true);
        }
    }