Input.GetAxis("Vertical") not working on Mobile Phone

Hi,

I’m a newbie in Unity Game Development. I’m currently working on a very basic 2D game. The following code works on my PC using arrow keys:

float yPos = gameObject.transform.position.y + (Input.GetAxis("Vertical") * playerSpeed);

playerPos = new Vector3(-23, Mathf.Clamp(yPos, -11, 11), 0);
gameObject.transform.position = playerPos;

But when I’m trying to test this game in my mobile phone, it’s not working. How can I get the swipe up and swipe down touch input?

One fantastic thing about Unity forum is no one replies, ever!!

However, I’ve figured this out. For other newbies, here’s the code:

float playerSpeed = 0.1F;

float yPos = gameObject.transform.position.y + (Input.GetTouch(0).deltaPosition.y * playerSpeed);

playerPos = new Vector3(-23, Mathf.Clamp(yPos, -12.6F, 12.6F), 0);
gameObject.transform.position = playerPos;