- Home /
Question by
Crossroad1000 · Dec 04, 2014 at 01:49 PM ·
objectdragfaststops
Touchinput with drag doesn't work fast
Hi there, I made a TouchInput.js for the camera and a reference to an object. But if I drag my object fast across my screen, it stops the drag because it probably thinks the gameobject isn't touched anymore. Only if I slowly move my object across the screen it works right.
This is the TouchInput script I made for the camera:
if (Input.touchCount > 0) {
touchesOld = new GameObject[touchList.Count];
touchList.CopyTo(touchesOld);
touchList.Clear();
foreach (Touch touch in Input.touches) {
Ray ray = camera.ScreenPointToRay(touch.position);
if (Physics.Raycast(ray,out hit,touchInputMask)) {
GameObject recipient = hit.transform.gameObject;
touchList.Add(recipient);
if (touch.phase == TouchPhase.Began) {
recipient.SendMessage("OnTouchDown",hit.point,SendMessageOptions.DontRequireReceiver);
}
if (touch.phase == TouchPhase.Moved) {
recipient.SendMessage("OnTouchDrag",hit.point,SendMessageOptions.DontRequireReceiver);
}
if (touch.phase == TouchPhase.Ended) {
recipient.SendMessage("OnTouchUp",hit.point,SendMessageOptions.DontRequireReceiver);
}
}
}
}
Can someone tell me what I have to change/add? :)
Comment
Your answer