Choppy Player Movement with WASD Keys

Hi, when ever I wrote my script for the PlayerMovement I encountered something unusual to me.
When the player presses the W or D keys he only goes either direction (forward or right) only once, but not continuously. This annoys me because I want the player to move continuously and smoothly across the platform. Any help? Thanks in advance :smiley:

The speed variable is just a float with a value of 3f.

The Code:

		//Player will move up/down or left/right according to which keys he/she presses.
		if (Input.GetKeyDown (KeyCode.D))
		transform.Translate (Vector3.right * Speed * Time.deltaTime);
		if (Input.GetKeyDown (KeyCode.W))
		transform.Translate (Vector3.forward * Speed * Time.deltaTime);

Input.GetKeyDown only fired when a key goes down. So to move forward, the player would have to hit the key over and over.

Input.GetKey fires as long as the key is pressed. So, you’d want to use that for continuous movement.

You can simply use Input.GetAxis (“Horizontal”) and Input.GetAxis (“Vertical”) instead. It catches the input from both the arrow keys and the WASD keys.

I use it in this way:

	// Move the character
	Vector3 force = new Vector3 (Input.GetAxis ("Horizontal") * MOVE_SPEED, 
	0.0f, // This is the Y axis; I don't move in the Y axis unless I jump
	Input.GetAxis ("Vertical") * MOVE_SPEED);

	gameObject.GetComponent<Rigidbody> ().AddForce (force);