rigidbody.AddForce not working with vector 3.

Here is my code:

float HeightToJumpTo () // How high should we jump to when we press space?
	{
		return Mathf.Sqrt (gravity * 2 * jumpHeight); // Setting HeightToJumpTo to the square root of 2 * gravity * jumpHeight.
	}

void Update ()
	{
		velocity = rigidbody.velocity;

		if (Input.GetButtonDown ("Jump") && grounded == true) 
		{
			print ("Jump");
			rigidbody.AddForce (new Vector3 (velocity.x, HeightToJumpTo (), velocity.z));
		}
	}

When I press the jump button, I am grounded and “Jump” is printed. However, the character capsule does not jump up, it should though.

What am I doing wrong? Thanks in advance.

you need set rigidbody.velocity not rigidbody.Addforce

One example for 2d :

//Gestisco controllo per il salto
		if (Input.GetKeyDown ("w")) {
				//Controllo se collide con il terrento e se posso eseguire il doppio salto
				if (grounded == true) {
						vspeed = JUMP_SPEED;
						double_jump = true;
				} else {
						if (double_jump == true) {
								double_jump = false;
								vspeed = JUMP_DOUBLE_SPEED;
						}
				}
	
		} else {
				vspeed = 0;
		}

		rigidbody2D.velocity = new Vector3 (hspeed, vspeed + rigidbody2D.velocity.y, 0);