Exemplo n.º 1
0
        private void Update()
        {
            if (Input.GetKey(KeyCode.Escape))
            {
                Cursor.visible     = true;
                _pauseMenu.enabled = true;
                _menuBehaviour.PauseGame();
            }

            _moveDirection.x = Input.GetAxis("Horizontal");
            _moveDirection.z = Input.GetAxis("Vertical");
            float moveRotation = Input.GetAxis("Mouse X") * _rotateSpeed;

            transform.Rotate(0, moveRotation, 0);

            //Run
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                _walk *= _run;
            }
            //Stop running
            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                _walk /= _run;
            }
            //Dash
            if (Input.GetKeyDown(KeyCode.Space) && _jumped && !_dashed)
            {
                _rb.velocity = transform.forward * _jump;
                _dashAudio.Play();
                if (!_dashed)
                {
                    _dashed = true;
                }
            }
            //Jump
            if (Input.GetKeyDown(KeyCode.Space) && !_jumped)
            {
                _rb.velocity = transform.up * _jump;
                _jumpAudio.Play();
                if (!_jumped)
                {
                    _jumped = true;
                }
            }
            //Interact with cubes
            if (Input.GetKeyDown(KeyCode.F))
            {
                _rayCube?.RayInteraction(this);
            }
        }