Change Direction While Jumping

I’m improving my jump (as shown in a previous question) and I’d like to make it so the player can still change direction while they’re jumping. Is there a way to implement this using my code (see below)? I also have a character motor attached, if that matters.

void Update()
	{
		CharacterController controller = GetComponent<CharacterController>();
		float rotation = Input.GetAxis("Horizontal");
		if(controller.isGrounded)
		{
			//jumpCount=2; //if on ground, 2 jumps can still be done
			
			moveDirection.Set(rotation, 0, 0); //moveDirection = new Vector3(rotation, 0, 0);
			moveDirection = transform.TransformDirection(moveDirection);
			if(Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
			{
				running = true;
			}
			else
			{
				running = false;
			}
			if(running)Debug.Log ("yes running");
			moveDirection *= running? runningSpeed : walkingSpeed;
			
			if(Input.GetButtonDown("Jump"))
			{
				moveDirection.y = jumpHeight;
				//rigidbody.AddForce(Vector3.up * jumpHeight);
			}
		}
		moveDirection.y -= gravity * Time.deltaTime;
		controller.Move(moveDirection * Time.deltaTime)
}//end update

Tack on an “else” statement after your “if(controller.isGrounded)” closes. Inside the else allow them to move (using the same concepts, moveDirection and stuff) but don’t allow them to jump (don’t put if(…“jump”)). Inside the else you could also make it so they can’t move as fast pretty easily.