Hello,
I am looking to improve my code for registering touch positions on the screen,. Right now i do it like this…
ObjectX_Position = Cam.camera.WorldToViewportPoint(ObjectX.transform.position);
if (Input.touchCount > 0 Input.GetTouch(0).phase == TouchPhase.Began)
{
t = Input.touches[0];
TouchStart = t.position;
TouchPosition = Cam.camera.ScreenToViewportPoint(TouchStart);
}
And then i compare these 2 variables like this… if (Vector2.Distance(TouchPosition,ObjectX_Position) < 0.1) { /* Rotate Object */ } …
But for some reason this is not accurate enough, it can happen for instance that if i touch the screen approximately 0.5 cm, outside this zone the touch will still be registered. Setting the margin to anything lower than 0.1 will not do, because then it won’t work at all… If some of you might happen to know a solution to this, i would be very pleased with your advice…
Thanks in advance,
Yours Truly.