How do i simulate a flythrough mode in the game?

Hi,I have the following script for flying in the game. by this code i can only fly in a flat plane with using WASD keys, but i want my flight be relative to which way the camera is facing in 3d space.How to do it? thankful

var speed = 60.0;
var jumpSpeed = 80.0;
var gravity = 0.0;

private var moveDirection = Vector3.zero;
private var grounded : boolean = false;

function FixedUpdate() 
{
	// Calculate the move direction
	moveDirection = new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical"));
	moveDirection = transform.TransformDirection(moveDirection);
	moveDirection *= speed;
	// Move the controller
	var controller : CharacterController = GetComponent(CharacterController);    
	controller.Move(moveDirection * Time.deltaTime);
}

You’d want to make a separate ‘move’ function, which you toggle between for walking / flying. In your ‘fly’ function, instead of using

moveDirection = transform.TransformDirection(moveDirection);

use

moveDirection = Camera.main.transform.TransformDirection(moveDirection);

This will make all of your movements relative to the camera.