Hey there i wrote a script which moves the camera around when a player moves his finger on the touchscreen.
My problem is that now clicking objects is nearly impossible because my touch/click on the smartphone isnt accurate enough, so it always pans a little and so clicking script isnt working. Sometimes it works but only if there is an accurate click on the same inputposition.
make sure that panning doesn’t occur unless a certain minimum movement is covered by input.
to do this, you record the origin of the touch and then track its coordinate, always getting the distance between the two.
you then configure a threshold for this distance. if the touch vanishes before this threshold is reached, it is interpreted as simple touch, and if the threshold is reached, it’s interpreted as pan instead.
3 Likes
Thanks this really helps i was able to solve it like this:
[B]private Vector3 mouseCoordinate;
private Vector3 mouseCoordinateMoved;[/B]
void Update()
{
[B] mouseCoordinateMoved = Input.mousePosition;[/B]
if (Input.GetMouseButtonDown(0) && checkTimeSet == false)
{
//Debug.Log("Start Holding");
[B]mouseCoordinate = Input.mousePosition;[/B]
holdDownStartTime = Time.time;
checkTimeSet = true;
}
if (checkTimeSet == true)
{
downTime = Time.time - holdDownStartTime;
if (downTime > waitTime && Input.GetMouseButtonUp(0) == false)
{
[B]float mouseDistance = Vector3.Distance(mouseCoordinate, mouseCoordinateMoved);
if (mouseDistance >= 2f)[/B]
{
Thank you very much for your help!