Get which way the player is moving from character controller.move

Hey guys,

I was wondering whats the best way to get which way the character is moving for example is it moving back or forward or strafing left or right.

I tried using
if(MoveVector.x <1)

But the problem with that is the player rotates and faces where the camera is facing and that will make it not valid.

This is how im moving my player at the moment.

void GetLocomotionInput()
	{
		var deadZone = 0.1f;

		TP_Motor.Instance.VerticalVelocity = TP_Motor.Instance.MoveVector.y;

		TP_Motor.Instance.MoveVector = Vector3.zero;

		if (Input.GetAxis("Vertical") > deadZone || Input.GetAxis("Vertical")< -deadZone)
		{
			TP_Motor.Instance.MoveVector += new Vector3(0, 0, Input.GetAxis("Vertical"));
		}

		if (Input.GetAxis("Horizontal") > deadZone || Input.GetAxis("Horizontal")< -deadZone)
		{
			TP_Motor.Instance.MoveVector += new Vector3(Input.GetAxis("Horizontal"), 0, 0);
		}

	}

Thanks in Advance.

You can determine the direction based on which keys are pressed.

		var x = Input.GetAxisRaw("Horizontal");
		var z = Input.GetAxisRaw("Vertical");

		if(x > deadZone) Debug.Log("Moving right");
		if(x < -deadZone) Debug.Log("Moving Left");
		if(z > deadZone) Debug.Log("Moving Forward");
		if(z < -deadZone) Debug.Log("Moving Backward");

Use the world forward vector and compare the player forward vector:

float dot = Vector3.Dot(transform.forward, Vector3.forward);
if(dot > 0.9) // going forward direction
else if (dot < - 0.9) // going opposite to forward direction
else{
     Vector3 cross = Vector3.Cross(transform.forward, Vector3.forward);
     // This could be the other way around...never remember which order
     if(cross.y < 0) // going right 
     else // going left 
}