controls like old game

I want to make a camera and character movement control set up that works like this:

  • W to walk forward.
  • A to rotate camera to the left.
  • D to rotate camera to the right.
  • S to walk back.
  • Mouse to look up and down or tilt the camera.

I have some code that does everything but the turning the camera to the left and right when I press the A or D key, instead the player [incorrectly] moves in that direction.

Here is the code I'm working with. I know it has something to do with rotate, transform and get key. Anyone that can point me in the right direction?

private var fpcMouse;
private var camMouse;

function Start () {

    fpcMouse = gameObject.Find("Player").GetComponent("MouseLook");
    camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");

}

function Update () {
    if (Input.GetKeyDown(KeyCode.Q)) {

        Screen.showCursor = !Screen.showCursor;
        Screen.showCursor = true;
        fpcMouse.enabled = !fpcMouse.enabled;
        camMouse.enabled = !camMouse.enabled;
    }
}

Have you tried the FPSController yet?

Also you can attach a camera component to your character and do something like:

transform.Rotate(0, Input.GetAxis("Horizontal"), 0);

However this will rotate the character using both A/D and left arrow/right arrow. You can change this using the input manager