Need help with characterController.move Function

I need some help, I am unable to figure out what to change to make this work locally instead of global, this code is from the scripting reference page under CharacterController.move… The transform.TransformDirection is suppose to make it global, I have removed it from script and also tried transform.InverseTransformDirection but to no avail any ideas out there?

#pragma strict
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Start () {

}

function Update () {
	var controller : CharacterController = GetComponent(CharacterController);
	if(controller.isGrounded){
		moveDirection = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
		moveDirection = transform.TransformDirection(moveDirection);
		moveDirection *= speed;
		if(Input.GetButton("Jump")){
			moveDirection.y = jumpSpeed;
		}
	}
	moveDirection.y -= gravity * Time.deltaTime;
	controller.Move(moveDirection * Time.deltaTime);
	
}

If there is a way to turn this local please point me out in the right direction.

Here is a quick and dirty solution:

#pragma strict
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Start () {
 
}
 
function Update () {
    var controller : CharacterController = GetComponent(CharacterController);
    if(controller.isGrounded){
       moveDirection = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
       var temp = moveDirection.y;
       moveDirection = Camera.main.transform.TransformDirection(moveDirection);
       moveDirection.y = temp;
       moveDirection *= speed;
       if(Input.GetButton("Jump")){
         moveDirection.y = jumpSpeed;
       }
    }
    moveDirection.y -= gravity * Time.deltaTime;
    controller.Move(moveDirection * Time.deltaTime);
 
}

It uses TransformDirection() of the camera instead of the character. I made an assumption here that you did not want it to impact ‘Y’ movement, so ‘Y’ movement is saved and restored so it is only used by jumping.