Ejemplo n.º 1
0
    void Update()
    {
        transform.SetLocalPositionY(
            Mathf.Clamp(transform.localPosition.y + Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * 50,
                        zoomConstraints[0],
                        zoomConstraints[1])
            );

        center.SetLocalEulerAnglesY(center.localEulerAngles.y - Input.GetAxis("Horizontal"));
        transform.SetLocalPositionZ(
            Mathf.Clamp(transform.localPosition.z + Input.GetAxis("Vertical") * 0.5f,
                        zConstraints[0],
                        zConstraints[1]));

        float   yLook = Mathf.Lerp(0f, zConstraints[0] / 2f, Mathf.InverseLerp(zConstraints[1], zConstraints[0], transform.localPosition.z));
        Vector3 look  = center.position;

        look.y = yLook;
        transform.LookAt(look);

        if (Input.GetMouseButtonDown(1))
        {
            dragging = true;
            StartCoroutine(CoMoveDrag(Input.mousePosition));
        }
        if (dragging && !Input.GetMouseButton(1))
        {
            dragging = false;
            lpfHorizontal.Reset();
            lpfVertical.Reset();
        }
    }