Question by
tbpthebluepickle · Feb 03, 2020 at 07:30 PM ·
mobile
How do I transfer keyboard inputs to button inputs
I'm trying to port this game I made to mobile by changing all keyboard inputs to on-screen button inputs but I don't know how to transfer the code. The keyboard inputs are written like this: private void Update() { transform.position = Vector2.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.UpArrow) && transform.position.y < maxHeight)
{
Instantiate(popSound, transform.position, Quaternion.identity);
Instantiate(effect, transform.position, Quaternion.identity);
targetPos = new Vector2(transform.position.x, transform.position.y + Yincrement);
}
else if (Input.GetKeyDown(KeyCode.DownArrow) && transform.position.y > minHeight)
{
Instantiate(popSound, transform.position, Quaternion.identity);
Instantiate(effect, transform.position, Quaternion.identity);
targetPos = new Vector2(transform.position.x, transform.position.y - Yincrement);
}
}
Is there a way to convert this to an Up and Down button on the screen?
Comment