Character Controller in Air Controlling Problem

Hey there guys…greetings from me…

i am have following code for my character controller and it works fine but not only for air…while character controller is in air it flickers…please anyone help me to fix it…thanks

{
    if (grounded) {
       


        moveDirection = Vector3(inputX , 0, inputY );
        moveDirection = myTransform.TransformDirection(moveDirection) * speed;
   

        //Jumping

        if (!Input.GetButton("Jump")

            moveDirection.y = jumpSpeed;
           
        }
    }
    else {
        //problem is here...it goes in random place
   
        moveDirection.x += inputX * speed/2 ;   
        moveDirection.z += inputY * speed/2 ;
        moveDirection = myTransform.TransformDirection(moveDirection);
       
    }
    // Apply gravity
    moveDirection.y -= gravity * Time.deltaTime;
    // Move the controller, and set grounded true or false depending on whether we're standing on something
    grounded = (controller.Move(moveDirection * Time.deltaTime) & CollisionFlags.Below) != 0;
}

try changing to this in your else

 moveDirection = Vector3(inputX , 0, inputY );
        moveDirection = myTransform.TransformDirection(moveDirection) * speed/2;

tried didnt work…

Can you describe the problemen a bit beter? What do you mean with flickers? Starts spinning? Or backward-forward bitter? Or…
Where is thuis code Calles? In Update? FixedUpdate?..