Player rotation affecting Top Down 2D Movement

As I’m attempting to control my character, from the perspective of the camera, when S is pressed, the character -always- moves directly south. However, the W,A,D keys move the character in a general north, east or west direction, respectively, As the player rotates via the mouse, the exact direct and speed changes.

Heres’a video of the behavior: Weird Motion - YouTube

And here’s my code:

#pragma strict

var speed : float = 20.0;
private var moveDirection : Vector3 =;

function Update () {
	var controller : CharacterController = GetComponent(CharacterController);
 	moveDirection = Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"), 0);
	moveDirection = Camera.main.transform.TransformDirection(moveDirection);
	moveDirection *= speed;
    // Move the controller
    controller.Move(moveDirection * Time.deltaTime);
	var position = Input.mousePosition;	
	var newPosition = Vector3(position.x, position.y, Camera.main.transform.position.y - transform.position.y);
	var lastPosition = Camera.main.ScreenToWorldPoint(newPosition);

@script RequireComponent(CharacterController)

Any suggestions or help would be greatly appreciated.


moveDirection = (transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal")) * speed;