void Update()
    {
        transform.Rotate(PlayerRotation.CalculateYRotation(_playerMovementInput.GetAxis("Mouse X"), _playerMovementInput.GetDeltaTime()));

        characterController.Move(PlayerGroundMovement.Calculate(_playerMovementInput.GetAxis("Horizontal"), _playerMovementInput.GetAxis("Vertical"), _playerMovementInput.GetDeltaTime()));

        characterController.Move(PlayerVerticalMovement.CalculateGravitationalEffectVector(_playerMovementInput.GetDeltaTime()));
    }
        public IEnumerator UpdateShouldRotateCameraAroundTheXAxisWhenMouseMovesAlongTheYAxis()
        {
            GameObject       cameraGameObject = new GameObject("Camera");
            CameraController cameraController = cameraGameObject.AddComponent <CameraController>();

            IPlayerMovementInput playerInput = Substitute.For <IPlayerMovementInput>();

            playerInput.GetAxis("Mouse Y").Returns(1);
            playerInput.GetDeltaTime().Returns(1);

            cameraController._playerInput = playerInput;

            Assert.AreEqual(0, cameraGameObject.transform.rotation.x, 0.1f);
            yield return(null);

            Assert.AreEqual(-0.7, cameraGameObject.transform.rotation.x, 0.1f);
        }
Example #3
0
        public IEnumerator UpdateShouldMovePlayerAlongXForHorizontalInput()
        {
            GameObject          playerGameObject    = new GameObject("Player");
            PlayerController    playerController    = playerGameObject.AddComponent <PlayerController>();
            CharacterController characterController = playerGameObject.AddComponent <CharacterController>();

            IPlayerMovementInput playerMovementInput = Substitute.For <IPlayerMovementInput>();

            playerMovementInput.GetAxis("Horizontal").Returns(1);
            playerMovementInput.GetDeltaTime().Returns(1);

            playerController._playerMovementInput = playerMovementInput;
            playerController.characterController  = characterController;

            Assert.AreEqual(0, playerGameObject.transform.position.x);
            yield return(null);

            Assert.AreEqual(12f, playerGameObject.transform.position.x);
        }
Example #4
0
        public IEnumerator UpdateShouldRotatePlayerAroundTheYAxisWhenMouseMovesAlongTheXAxis()
        {
            GameObject          playerGameObject    = new GameObject("Player");
            PlayerController    playerController    = playerGameObject.AddComponent <PlayerController>();
            CharacterController characterController = playerGameObject.AddComponent <CharacterController>();

            IPlayerMovementInput playerMovementInput = Substitute.For <IPlayerMovementInput>();

            playerMovementInput.GetAxis("Mouse X").Returns(1);
            playerMovementInput.GetDeltaTime().Returns(1);

            playerController._playerMovementInput = playerMovementInput;
            playerController.characterController  = characterController;

            Assert.AreEqual(0, playerGameObject.transform.rotation.y);
            yield return(null);

            Assert.AreEqual(0.8, playerGameObject.transform.rotation.y, 0.1f);
        }
Example #5
0
 void Update()
 {
     transform.localRotation = CameraRotation.CalculateXRotation(_playerInput.GetAxis("Mouse Y"), _playerInput.GetDeltaTime());
 }