how to have continuous touch on a mobile device?
Hi everyone! first time using these unity forums and I have a problem regarding a mobile game i am making for a class. I am trying to get continuous touch to work on my android. I currently have it to where I can press the up, down, left or right buttons and my player will move in which ever direction. The thing is, i have to keep pressing the buttons(like if I wanted to move left, i would press the left button) in order for the player to move continuously. How can I get it to where I can press and hold a button so the touch will be continuous?? I am aware that you can use OnPointerDown and OnPointerExit but I don't know how to apply that to my buttons either..I am going to attach my mobile button script so you guys can see what I mean. I would really appreciate some help on this!
using UnityEngine; using System.Collections;
public class MobileButtons : MonoBehaviour { public GameObject player;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
public void OnButtonClickUp()
{
player.transform.Translate(Vector3.forward * -10f * Time.deltaTime);
}
public void OnButtonClickDown()
{
player.transform.Translate(Vector3.back * -10f * Time.deltaTime);
}
public void OnButtonClickLeft()
{
player.transform.Translate(Vector3.left * -10f * Time.deltaTime);
}
public void OnButtonClickRight()
{
player.transform.Translate(Vector3.right * -10f * Time.deltaTime);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612092232im_/https://answers.unity.com/themes/thub/images/avi.jpg)