Move Camera only along y and z axis, but not both?

I am trying to make my camera move when you press WASD or Arrow Keys. I can make it move, however, the problem is that the camera is at an angle, so whenever I move it, it goes on both axis, slightly. Is there a way to fix this? My line of code is in the update function:

transform.Translate(new Vector3(Input.GetAxis ("Horizontal"), Input.GetAxis("Vertical"), 0.0f));

There are a couple of different ways to interpret your question. I’m going to assume you want to move forward along the XZ plane in the direction your are facing, and you want to go up and down in the world ‘y’ axis. I’m going to assume you want to move smoothly over time, not make immediate jumps. You need to scale your movements by Time.deltaTime, and you probably should introduce a speed variable.

At the top of the file:

var speed = 2.0; 

In Update():

float horz = Input.GetAxis ("Horizontal");
float vert = Input.GetAxis("Vertical");

Vector3 v = transform.forward;
v.y = 0;

transform.position += v * horz * speed * Time.deltaTime;
transform.position += Vector3.up * vert * Time.deltaTime;