Пример #1
0
        private void RotateView()
        {
            //DCURRY added else for mobile input
#if !MOBILE_INPUT
            Vector2 mouseInput = _mouseLook.Clamped(_yRotation, transform.localEulerAngles.y);

            _camera.transform.localEulerAngles = new Vector3(-mouseInput.y, _camera.transform.localEulerAngles.y,
                                                             _camera.transform.localEulerAngles.z);
            transform.localEulerAngles = new Vector3(0, mouseInput.x, 0);
#else
            Vector2 mouseInput = new Vector2(CrossPlatformInputManager.GetAxisRaw("HorizontalLook"),
                                             CrossPlatformInputManager.GetAxisRaw("VerticalLook"));

            float camX = _camera.transform.localEulerAngles.x;

            if ((camX > 280 && camX <= 360) ||
                (camX >= 0 && camX < 80) ||
                (camX >= 80 && camX < 180 && mouseInput.y > 0) ||
                (camX > 180 && camX <= 280 && mouseInput.y < 0))
            {
                _camera.transform.localEulerAngles += new Vector3(-mouseInput.y * lookSpeed * .7f, _camera.transform.localEulerAngles.y,
                                                                  _camera.transform.localEulerAngles.z);
            }

            transform.localEulerAngles += new Vector3(0, mouseInput.x * lookSpeed, 0);
#endif
            // handle the roation round the x axis on the camera

            _yRotation = mouseInput.y;
            _cameraRefocus.GetFocusPoint();
        }
    private void RotateView()
    {
        // get the rotation before it's changed
        float   oldYRotation = transform.eulerAngles.y;
        Vector2 mouseInput   = mouseLook.Clamped(yRotation, transform.localEulerAngles.y);

        // handle the rotation round the x axis on the camera
        _camera.transform.localEulerAngles = new Vector3(-mouseInput.y, _camera.transform.localEulerAngles.y, _camera.transform.localEulerAngles.z);
        yRotation = mouseInput.y;
        transform.localEulerAngles = new Vector3(0, mouseInput.x, 0);

        if (isGrounded || advancedSettings.airControl)
        {
            // Rotate the rigidbody velocity to match the new direction that the character is looking
            Quaternion velRotation = Quaternion.AngleAxis(transform.eulerAngles.y - oldYRotation, Vector3.up);
            RigidBody.velocity = velRotation * RigidBody.velocity;
        }
    }