I have three buttons on screen ‘UP_KEY’, ‘RIGHT_KEY’ and ‘LEFT_KEY’ I need to be able to touch these three buttons at the same time and be able to hold ‘RIGHT_KEY’ and ‘LEFT_KEY’ to make the player continuously move left or right.
I have used this to detect a touch but I can’t seem to get the TouchPhase.Ended to execute
void Update () {
foreach (Touch touch in Input.touches)
if (touch.phase == TouchPhase.Stationary)
ray = Camera.main.ScreenPointToRay (touch.position);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast (ray,out hit,1000.0f))
if(hit.collider.gameObject == this.gameObject)
moveplayerRight = 1;
foreach (Touch touch in Input.touches)
if (touch.phase == TouchPhase.Ended)
moveplayerRight = 0;
Have I donE something drastically wrong? I have only been doing this for a week now and I can’t wrap my head around these touch controls.e