Exemplo n.º 1
0
    void HandleCamera()
    {
        if (MouseLock.GetMouseLocked())
        {
            sphericalVectorData.Azimuth += Input.GetAxis("Mouse X") * orbitSpeed.x;
            sphericalVectorData.Zenith  += Input.GetAxis("Mouse Y") * orbitSpeed.y;
        }

        sphericalVectorData.Zenith = Mathf.Clamp(sphericalVectorData.Zenith + orbitOffset.x, orbitOffset.y, 0f);

        float distanceToObject = zoomValue;
        float deltaDistance    = Mathf.Clamp(zoomValue, distanceToObject, -distanceToObject);

        sphericalVectorData.Length += (deltaDistance - sphericalVectorData.Length);

        Vector3 lookAt = targetOffset;

        lookAt += playerTarget.position;

        base.Update();

        transform.position += lookAt;
        transform.LookAt(lookAt);

        if (zoomValue == cameraLengthZoom)
        {
            Quaternion targetRotation = transform.rotation;
            targetRotation.x      = 0f;
            targetRotation.z      = 0f;
            playerTarget.rotation = targetRotation;
        }
        cameraPosition = cameraPositionTemporary;
        zoomValue      = cameraLength;
    }
Exemplo n.º 2
0
 void HandleMouseLocking()
 {
     if (Input.GetKeyDown(KeyCode.Tab))
     {
         if (MouseLock.GetMouseLocked())
         {
             MouseLock.SetMouseLocked(false);
         }
         else
         {
             MouseLock.SetMouseLocked(true);
         }
     }
 }