TransformDirection use only y

My character moves very slow when looking up or down and i dont know how to make transform use only y for rotation

using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float walkSpeed = 6.0f;
    public float runSpeed = 10.0f;
    public float jumpSpeed = 8.0f;
    public float gravity = 10.0f;
    public GameObject playerCamera;
    private Vector3 moveDirection = Vector3.zero;
    private CharacterController controller;
    private bool Jumping;
    private bool Running;
    private bool CanJump;
    private bool CanRun;

    void Start()
    {
        controller = GetComponent<CharacterController>();
        CanJump = true;
        Jumping = false;
        CanRun = true;
        Running = false;
    }

    void Update()
    {
        if (controller.isGrounded)
        {
            if (Jumping)
            {
                Jumping = false;
                CanJump = false;
                Running = false;
                CanRun = false;
                playerCamera.GetComponent<Animation>().Play();
                Invoke("SetBoolBack", 1f);
            }

            moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));
            moveDirection = playerCamera.transform.TransformDirection(moveDirection);
            moveDirection = new Vector3(moveDirection.x, 0f, moveDirection.z);

            if (Input.GetButton("Run") && CanRun)
            {
                moveDirection = moveDirection * runSpeed;
            }
            else
            {
                moveDirection = moveDirection * walkSpeed;
            }
          
            if (Input.GetButton("Jump") && CanJump)
            {
                Jumping = true;
                moveDirection.y = jumpSpeed;
            }
        }

        moveDirection.y = moveDirection.y - (gravity * Time.deltaTime);

        controller.Move(moveDirection * Time.deltaTime);
    }

    private void SetBoolBack()
    {
        CanJump = true;
        CanRun = true;
    }
}

kinda fixed it but its bad any1 can tell me better solution?
using UnityEngine;

public class LockRotation : MonoBehaviour {
    public Transform cam;
    private float rotY;
    void Update ()
    {
        rotY = cam.eulerAngles.y;
        Quaternion localRotation = Quaternion.Euler(0.0f, rotY, 0.0f);
        transform.rotation = localRotation;
    }
}