My character walks slower when looking down?

Here is my third-person movement script:

float h = Input.GetAxis("leftH");
float v = Input.GetAxis("leftV") * -1;
Vector3 newDirection = new Vector3(h, 0, v);
Vector3 newDirectionInWorld = Camera.main.transform.TransformDirection(newDirection);
newDirectionInWorld *= moveSpeed;
newDirectionInWorld.y -= gravity * Time.deltaTime;
charController.Move(newDirectionInWorld * Time.deltaTime);      

when i look down my character walks slower, why?

It is happening because your character wants to walk down/up when looking up/down. I have one trick to prevent this weird behaviour (Alghoritm):

  1. Set capsule rotation (if player model is capsule etc.) to x rotation of a camera (in euler angles)
  2. Get capsule transform.forward vector
  3. Multiply it by walk speed and delta time (for better movement)
  4. Your character is ready to test

You can also set rotation of player entire game object. This is only trick.