Пример #1
0
    /// <summary>
    /// Camera Rotation behaviour
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    public void RotateCamera(float x, float y, bool gamepad)
    {
        // free rotation
        float xSen = gamepad ? xGamepadSensitivity : xMouseSensitivity;
        float ySen = gamepad ? yGamepadSensitivity : yMouseSensitivity;


        mouseX += x * xSen;
        mouseY -= y * ySen;

        movementSpeed.x = x;
        movementSpeed.y = -y;

        if (!lockCamera)
        {
            mouseY = AngleClamper.ClampAngle(mouseY, yMinLimit, yMaxLimit);
            mouseX = AngleClamper.ClampAngle(mouseX, xMinLimit, xMaxLimit);
        }
        else
        {
            //mouseY = currentTarget.root.localEulerAngles.x;
            //mouseX = currentTarget.root.localEulerAngles.y;

            //XValue = 0;
            mouseX = currentTarget.eulerAngles.y;
        }
    }
Пример #2
0
    public void RotateX(float mouseX)
    {
        Transform camTransform = Camera.main.transform;

        camTransform.Rotate(Vector3.right * -mouseX * rotationSpeed /* Time.deltaTime*/);
        Vector3 currentRotation = camTransform.localRotation.eulerAngles;

        currentRotation.x          = AngleClamper.ClampBetweenAngles(currentRotation.x, -80, 80);
        camTransform.localRotation = Quaternion.Euler(currentRotation);
    }