Player movement script like in FPS, Unity3d
<p>I have 2 scripts, which make player move like in the FPS game. But it don't move to that direction, to which player are looking - it always move to the same direction, regardless of the direction of the camera.. </p>

<p><strong>mouselook.cs</strong></p>

<pre><code>float yRotation;
float xRotation;
float lookSensitivity = 5;
float currentXRotation;
float currentYRotation;
float yRotationV;
float xRotationV;
float lookSmoothnes = 0.1f; 

void Update ()
{
    yRotation += Input.GetAxis("Mouse X") * lookSensitivity;
    xRotation -= Input.GetAxis("Mouse Y") * lookSensitivity;
    xRotation = Mathf.Clamp(xRotation, -80, 100);
    currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, ref xRotationV, lookSmoothnes);
    currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, ref yRotationV, lookSmoothnes);
    transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
}
</code></pre>

<p><strong>playermovement.cs</strong></p>

<pre><code>public float walkSpeed = 6.0F;
public float jumpSpeed = 8.0F;
public float runSpeed = 8.0F;
public float gravity = 20.0F;

private Vector3 moveDirection = Vector3.zero;
private CharacterController controller;

void Start()
{
    controller = GetComponent&lt;CharacterController&gt;();
}

void Update()
{
    if (controller.isGrounded)
    {
        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= walkSpeed;
        if (Input.GetButton("Jump"))
            moveDirection.y = jumpSpeed;
    }
    moveDirection.y -= gravity * Time.deltaTime;
    controller.Move(moveDirection * Time.deltaTime);
}
</code></pre>