,move vertical in 2d game

I’m new and I have a hard time finding out how you can move vertical(walk up/down) in a limited space for example to dodge bullet. Games that has this: mighty night 2(browser game)

picture of what I mean : https://goo.gl/images/uLTK68

Learn about how to use Input.GetAxis (), and how to adjust a transform’s position.
I would probably do something like this:

// Pseudocode (I haven't tested this):
void Update () {
float x = Input.GetAxis ("Horizontal");
float y = Input.GetAxis ("Vertical");

Vector3 input = new Vector3 (x, y, 0);

transform.position += input * movementSpeed;
}

Let me know if it dosn’t work.