Exemplo n.º 1
0
    private void PlayerMovement()
    {
        float horizInput = GameInputManager.getAxis(GameInputManager.Axis.Horizontal) * playerSpeed;
        float vertInput  = GameInputManager.getAxis(GameInputManager.Axis.Vertical) * playerSpeed;

        Vector3 fowardMovement;
        Vector3 rightMovement;

        if (!isSprinting)
        {
            fowardMovement = transform.forward * vertInput;
            rightMovement  = transform.right * horizInput;
        }
        else
        {
            fowardMovement = transform.forward * vertInput * sprintMultiplier;
            rightMovement  = transform.right * horizInput * sprintMultiplier;
        }

        if (vertInput != 0 || horizInput != 0)
        {
            isMoving = true;
        }
        else
        {
            isMoving = false;
        }

        charController.SimpleMove(fowardMovement + rightMovement);

        JumpInput();
        SprintInput();
        setAudio();
    }