In air movement issue

I’m having some issues with my movement code when it comes to jumping. It’s a code set up for a first person camera, the camera rotation is in a separate code. Here is the code clip:

using UnityEngine;
using System.Collections;

  public class CharacterMovement : MonoBehaviour 
    	public float speed = 10.0F;

public Vector3 airSpeed =;
	public float jumpSpeed = 8.0F;
	public float gravity = 20.0F;
	private Vector3 moveDirection =;
	// Update is called once per frame
	void Update ()
		CharacterController controller = GetComponent<CharacterController>();
			moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;
		if (Input.GetButton("Jump") && controller.isGrounded)
			moveDirection.y = jumpSpeed;
			airSpeed = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"))*0.2F;
			moveDirection +=airSpeed;
		moveDirection.y -= gravity * Time.deltaTime;
		controller.Move(moveDirection * Time.deltaTime);

Everything works fine expect for the in air movement. It seems to be using the airSpeed variable on a global axis instead of a local axis, so if I’m facing West in the world, my character will move to his right while jumping instead of forward when the up arrow or ‘W’ is pressed. Basically, the movement code for when isGrounded==false is causing the character to move on a global axis instead of a local axis so he is moving the wrong direction. Any ideas how to change that?

There is a call to TransformDirection() missing in the block where you figure out the midair movement. But I think you actually need to remove this entire block, since you handle vertical moevement elsewhere. The airspeed vector always has the y value (the vertical axis) set to 0, so it doesn’t affect vertical movement at all.

If you want the player to be able to change horizontal direction midair, also remove the first controller.isGrounded condition.

I guess I forgot to explain the air movement a bit. I would like the player to be able to move in mid-air, but at a much slower rate. So when the player jumps forward, mid air you should still move forward at the same speed at which you jumped, but you can affect the movement slightly. So think something along the lines of Halo is kind of what I’m going for here. In which case, would I still be able to get rid of the isGrounded condition?