Hello I have a problem with touches in Unity 2020.1
first i made a very simple script:
void Update(){
UiText.text = Input.touchCount.ToString();
}
This script should just show count of touch in every frame. I plug in a phone(Android) and click Ctrl+B = Build And Run. Everything was fine, application build and run on my mobile device but count of touch was always 0, but i touch multiple times. Ok, them I create another very simple scene and simple script. Scene: plane, cube and camera watching them. Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.collider != null)
{
Debug.Log("wow");
}
}
}
}
}
I check in the development build but application seem's to dont read touches from my device. I dont know why. Can you please help me?
Your answer
Follow this Question
Related Questions
Simple touch counting program not working 0 Answers
buttons vs touch. 1 Answer
How do I make a rigid body move towards position of touch 0 Answers
Unity Touch Pan Orthographic camera, 0 Answers
Clicker Attack 0 Answers