# velocity.x and velocity.y 2d noob question

void Update () {

``````	if (Input.GetKeyDown(KeyCode.Space)) {
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
}

if (Input.GetKey(KeyCode.D)) {
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}

if (Input.GetKey(KeyCode.A)) {
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
}
``````

im having difficulty understanding why is it that velocity.x is used for making the player jump? why not use velocity.y as a vertical motion? i thought in math x is the horizontal axis while y is the vertical am i wrong? Thank you

GetComponent().velocity = new Vector2(GetComponent().velocity.x, jumpHeight);

this line means:

take original velocity_x, set new velocity_y = jumpHeight, and apply this combination back to original velocity

so here we changing Y but not changing X component, taking it AS IS