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