Пример #1
0
    public bool keepDirection;                 // keep the current direction in case you change the cameraState

    public virtual void CameraInput()
    {
        if (!Camera.main)
        {
            Debug.Log("Missing a Camera with the tag MainCamera, please add one.");
        }
        if (!ignoreCameraRotation)
        {
            RotateWithCamera(Camera.main.transform);
        }

        if (cam == null)
        {
            return;
        }

        var Y = playerActions.MoveMouse.Y;
        var X = playerActions.MoveMouse.X;

        //var zoom = Input.GetAxis("Mouse ScrollWheel");

        cam.RotateCamera(X, Y);
        //tpCamera.Zoom(zoom);

        // change keepDirection from input diference
        if (keepDirection && Vector2.Distance(blackboard.input, blackboard.oldInput) > 0.2f)
        {
            keepDirection = false;
        }

        if (playerActions.LockOn.WasPressed)
        {
            blackboard.lockOnPressed = true;
        }
    }
Пример #2
0
        protected virtual void CameraInput()
        {
            if (!cameraMain)
            {
                if (!Camera.main)
                {
                    Debug.Log("Missing a Camera with the tag MainCamera, please add one.");
                }
                else
                {
                    cameraMain      = Camera.main;
                    cc.rotateTarget = cameraMain.transform;
                }
            }

            if (cameraMain)
            {
                cc.UpdateMoveDirection(cameraMain.transform);
            }

            if (tpCamera == null)
            {
                return;
            }

            var Y = Input.GetAxis(rotateCameraYInput);
            var X = Input.GetAxis(rotateCameraXInput);

            tpCamera.RotateCamera(X, Y);
        }
Пример #3
0
    protected virtual void CameraInput()
    {
        if (tpCamera == null)
        {
            return;
        }

        bool  gamepad = false;
        float Y       = 0;
        float X       = 0;

        if (tpInput.Gamepad != null && tpInput.Gamepad.IsConnected && tpInput.Gamepad.IsMovingEitherThumbStick)
        {
            gamepad = true;
            Y      += tpInput.Gamepad.GetStick_R().Y;
            X      += tpInput.Gamepad.GetStick_R().X;
        }
        else
        {
            Y = MouseInput.MouseY();
            X = MouseInput.MouseX();
        }

        tpCamera.RotateCamera(X, Y, gamepad);

        // tranform Character direction from camera if not KeepDirection
        if (keepDirection)
        {
            //Debug.Log("Keep Direction");
            // rotate the character with the camera while strafing
            RotateModelWithAnotherTransform(tpCamera.transform);
            RotateObjectWithAnotherTransform(tpCamera.transform);
        }
        else
        {
            if (horizontalDirectionKeep)
            {
                if (tpInput.ForwardOrBackwardMovementInputPushed)
                {
                    if (tpInput.InputDirection.y > 0)
                    {
                        if (tpInput.InputDirection.x > 0)
                        {
                            SidewaysFacing(tpCamera.transform, true, true);
                        }
                        else if (tpInput.InputDirection.x < 0)
                        {
                            SidewaysFacing(tpCamera.transform, false, true);
                        }
                    }
                    else
                    {
                        if (tpInput.InputDirection.x > 0)
                        {
                            SidewaysFacing(tpCamera.transform, true, true, true);
                        }
                        else if (tpInput.InputDirection.x < 0)
                        {
                            SidewaysFacing(tpCamera.transform, false, true, true);
                        }
                    }
                }
                else
                {
                    if (tpInput.InputDirection.x > 0)
                    {
                        SidewaysFacing(tpCamera.transform, true, false);
                    }
                    else if (tpInput.InputDirection.x < 0)
                    {
                        SidewaysFacing(tpCamera.transform, false, false);
                    }
                }
            }
        }
    }